squidfunk / mkdocs-material

Documentation that simply works

Home Page:https://squidfunk.github.io/mkdocs-material/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regression from 8.2.16 to 8.3.0: 'dict object' has no attribute 'hide'

ftrader opened this issue · comments

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

A CI job in our project which uses mkdocs stopped.

After some investigation we found the principal problem to be related to the upgrade of the mkdocs-material external dependency (it is installed via pip3 during the job setup).

Pinning to 8.2.16 fixes the issue.


NOTE: I was unable to test the first two checks

... 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

Do feel free to close this issue directly due to unmet "checks".

If it helps someone else experiencing this issue to learn that they can fix this by sticking to 8.2.16 for now, I count it as a win.

Expected behaviour

No regression of this feature.

Actual behaviour

Extract of the failure with Python traceback:

ERROR    -  Error building page 'README.md': 'dict object' has no attribute 'hide'
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mkdocs/__main__.py", line 192, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/usr/local/lib/python3.7/dist-packages/mkdocs/commands/build.py", line 314, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/usr/local/lib/python3.7/dist-packages/mkdocs/commands/build.py", line 217, in _build_page
    output = template.render(context)
  File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 1289, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 924, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.7/dist-packages/material/main.html", line 4, in top-level template code
    {% extends "base.html" %}
  File "/usr/local/lib/python3.7/dist-packages/material/base.html", line 178, in top-level template code
    {% block footer %}
  File "/usr/local/lib/python3.7/dist-packages/material/base.html", line 179, in block 'footer'
    {% include "partials/footer.html" %}
  File "/usr/local/lib/python3.7/dist-packages/material/partials/footer.html", line 6, in top-level template code
    {% set hidden = "hidden" if "footer" in page.meta.hide %}
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'hide'

Steps to reproduce

The issue was reproducible by restarting our CI job - it failed reliably with the same Python traceback.

Package versions

  • Python: 3.7.3 (presumed since Debian buster based docker image used on our CI)
  • MkDocs: 1.3.0
  • Material: 8.3.0

Configuration

Unable to pare it down to a minimal one. Feel free to close on that account.

https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/blob/master/doc/mkdocs.yml.in

System information

  • Operating system: Debian Buster
  • Browser: n/a (problem prevents doc build)

Linking to the Issue on the GitLab repo where this regression was detected in CI:

https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/issues/430

Thanks for reporting – my bad! Fixed in e3bea56. We missed a safeguard to check whether page.meta is defined, which is not true for static templates. Since you did not provide a minimal reproducible example, I can't say for sure when this was triggered, but it should be fixed by the change in the referenced commit.

On a side note, I did a slight refactoring and removed unnecessary safe guards in 95f8047.

Released as part of 8.3.1.

Thanks a lot for the quick fix. I'll test it on our CI pipeline and let you know if it worked for us.

Tested in our pipeline with 8.3.2, all good. Thanks again @squidfunk