Skip to content

Privacy plugin no longer works with extra_javascript configured #5772

@jonaharagon

Description

@jonaharagon

Context

When I upgrade mkdocs-material and my site dependencies from 9.1.18+insiders.4.37.0 to the current commit, my site can no longer be built.

Bug description

The build fails when extra_javascript is configured in mkdocs.yml and the privacy plugin is enabled.

INFO    -  DeprecationWarning: pkg_resources is deprecated as an API
             File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/material/plugins/info/plugin.py", line 33, in <module>
               from pkg_resources import get_distribution, working_set
             File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 121, in <module>
               warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/jonah/GitHub/mkdocs-testing/site
Traceback (most recent call last):
  File "/Users/jonah/GitHub/mkdocs-testing/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/mkdocs/__main__.py", line 286, in build_command
    build.build(cfg, dirty=not clean)
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 304, in build
    files = config.plugins.on_files(files, config=config)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/mkdocs/plugins.py", line 533, in on_files
    return self.run_event('files', files, config=config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonah/GitHub/mkdocs-testing/venv/lib/python3.11/site-packages/material/plugins/privacy/plugin.py", line 110, in on_files
    url = urlparse(path)
          ^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/parse.py", line 394, in urlparse
    url, scheme, _coerce_result = _coerce_args(url, scheme)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/parse.py", line 133, in _coerce_args
    return _decode_args(args) + (_encode_result,)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/parse.py", line 117, in _decode_args
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/parse.py", line 117, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
                 ^^^^^^^^
AttributeError: 'ExtraScriptValue' object has no attribute 'decode'

Related links

Reproduction

example.zip

Also, I had to set plugins.info.archive_stop_on_violation: false, otherwise it would say Please update from 9.1.20+insiders.4.37.0 to 9.2.0b2. even though 9.2.0b2 is not available on the insiders repo. Bonus bug? This reproduction ZIP is built with the latest (https://github.com/squidfunk/mkdocs-material-insiders/commit/d2033e5aee7d006f15b5d872834875f221bc6d23) commit though.

Steps to reproduce

  1. Enable the privacy plugin
  2. Add a JS file to extra_javascript in mkdocs.yml

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