E416 Privacy plugin raises error when site_url is null · Issue #4515 · squidfunk/mkdocs-material · GitHub
[go: up one dir, main page]

Skip to content

Privacy plugin raises error when site_url is null #4515

@wilhelmer

Description

@wilhelmer

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

When the privacy plugin is enabled and the site_url parameter isn't set, building the project fails.

To reproduce, create a minimal MkDocs project using the mkdocs.yml below.

Error message:

Traceback (most recent call last):
  File "/opt/homebrew/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/mkdocs/__main__.py", line 250, in build_command
    build.build(cfg, dirty=not clean)
  File "/opt/homebrew/lib/python3.10/site-packages/mkdocs/commands/build.py", line 332, in build
    config.plugins.run_event('post_build', config=config)
  File "/opt/homebrew/lib/python3.10/site-packages/mkdocs/plugins.py", line 519, in run_event
    result = method(**kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/material/plugins/privacy/plugin.py", line 187, in on_post_build
    self._fetch_dependents(f.read(), file, config),
  File "/opt/homebrew/lib/python3.10/site-packages/material/plugins/privacy/plugin.py", line 335, in _fetch_dependents
    url = posixpath.join(config.site_url, file.url)
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Expected behaviour

We should be able to build a project even when the site_url parameter is omitted, i.e., is null.

Actual behaviour

See description.

Steps to reproduce

See description.

Package versions

  • Python: 3.10.8
  • MkDocs: 1.4.1
  • Material: mkdocs-material-8.5.6-insiders-4.26.0

Configuration

site_name: Test Project
theme:
    name: material
use_directory_urls: false
nav:
  - Welcome: index.md
plugins:
  - privacy

System information

  • Operating system: macOS Ventura
  • Browser: Firefox

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

      0