Skip to content

Social plugin: runtime error with generated files #7520

@thorstenpeter-sophos

Description

@thorstenpeter-sophos

Context

No response

Bug description

When using the Insiders version of the Social plugin in combination with another plugin that creates generated files, it raises an AttributeError exception.

Generated files were added with mkdocs 1.6 and don't have an abs_scr_path attribute.

Related links

Reproduction

9.5.34+insiders.4.53.12-social-virtual-files-error.zip

The foo plugin used in the reproduction is defined as follows:

from mkdocs.plugins import BasePlugin from mkdocs.structure.files import File, Files, InclusionLevel class FooPlugin(BasePlugin): def on_files(self, files: Files, **kwargs): return files.append(File.generated( config=kwargs.get("config"), src_uri="foo.md", content="", inclusion=InclusionLevel.NOT_IN_NAV, )) 

Steps to reproduce

Run mkdocs build in the reproduction.

The build will fail with the following exception:

File "C:\git\mkdocs_material_insiders_minimal_reproduction\venv\Lib\site-packages\mkdocs\plugins.py", line 566, in run_event result = method(item, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\git\mkdocs_material_insiders_minimal_reproduction\venv\Lib\site-packages\material\plugins\social\plugin.py", line 180, in on_files if file.abs_src_path.startswith(_templates_dirpath()): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'startswith' 

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions