Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Privacy plugin raises error when site_url is null #4515

Closed
5 tasks done
wilhelmer opened this issue Oct 19, 2022 · 3 comments
Closed
5 tasks done

Privacy plugin raises error when site_url is null #4515

wilhelmer opened this issue Oct 19, 2022 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@wilhelmer
Copy link
Contributor

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
@wilhelmer wilhelmer changed the title Privacy plugin raises error when site_url is omitted Privacy plugin raises error when site_url is null Oct 19, 2022
@squidfunk squidfunk added the bug Issue reports a bug label Oct 19, 2022
@squidfunk
Copy link
Owner

squidfunk commented Oct 19, 2022

Thanks for reporting. Confirmed, looking into it. Only happens on mkdocs build, not on mkdocs serve.

@squidfunk
Copy link
Owner

squidfunk commented Oct 19, 2022

Fixed in squidfunk/mkdocs-material-insiders@14aa10899.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Oct 19, 2022
@squidfunk
Copy link
Owner

Released as part of 8.5.7+insiders-4.26.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants