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

Build fails under these conditions: mkdocs 1.4.0, material 8.5.3+insiders.4.24.0, consent present, repo_url missing #4430

Closed
5 tasks done
ben519 opened this issue Sep 30, 2022 · 5 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@ben519
Copy link
Sponsor

ben519 commented Sep 30, 2022

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 I attempt to build my site, I get the following error

$ python3 -m mkdocs serve

INFO     -  Building documentation...
INFO     -  Cleaning site directory
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/__main__.py", line 301, in <module>
    cli()
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/commands/build.py", line 320, in build
    _build_theme_template(template, env, files, config, nav)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/commands/build.py", line 118, in _build_theme_template
    output = _build_template(template_name, template, files, config, nav)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/mkdocs/commands/build.py", line 97, in _build_template
    output = template.render(context)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/material/404.html", line 4, in top-level template code
    {% extends "main.html" %}
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/material/main.html", line 4, in top-level template code
    {% extends "base.html" %}
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/material/base.html", line 211, in top-level template code
    {% include "partials/consent.html" %}
  File "/Users/bgorman/GormAnalysis Dropbox/Ben Gorman/Projects/Python/material-broken/venv/lib/python3.10/site-packages/material/partials/consent.html", line 10, in top-level template code
    {% if "github.com" in config.repo_url %}
TypeError: argument of type 'NoneType' is not iterable

The error is due to Jinja's in operator being used with a None value inside consent.html. Specifically, this line

    {% if "github.com" in config.repo_url %}
TypeError: argument of type 'NoneType' is not iterable

If these conditions are present, you should be able to reproduce this:

  • mkdocs 1.4.0,
  • material 8.5.3+insiders.4.24.0
  • consent present in mkdocs.yml
  • repo_url not present in mkdocs.yml

Strangely, this only occurred when I upgraded to mkdocs 1.4.0.

Expected behaviour

Site should build without error.

Actual behaviour

See the error above.

Steps to reproduce

I've published an example repo you can clone to reproduce this error.

git clone https://github.com/ben519/material-broken.git
cd material-broken

export GH_TOKEN=XYZToken
python3 -m pip install mkdocs git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git --upgrade

python3 -m mkdocs serve

Package versions

Python 3.10.6
mkdocs, version 1.4.0
Version: 8.5.3+insiders.4.24.0

Configuration

site_name: ABC
# repo_url: https://github.com/squidfunk/mkdocs-material  # uncomment this line and the build works

theme:
  name: material

extra:
  consent:
    title: Cookie consent
    description: hello world

nav:
  - Home: index.md
  - Dogs:
    - dogs/index.md
    - Golden Retrievers:
      - Golden Retrievers: dogs/golden-retrievers/index.md
      - Movies: dogs/golden-retrievers/movies.md

System information

Mac OS 12.6
Chrome Version 105.0.5195.125 (Official Build) (arm64)

@squidfunk
Copy link
Owner

Thanks for reporting. This is fixed on master.

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open labels Sep 30, 2022
@ben519
Copy link
Sponsor Author

ben519 commented Sep 30, 2022

Thanks for reporting. This is fixed on master.

Thanks for getting to this so quickly! Has the commit been pushed? I don't see it.

@ben519
Copy link
Sponsor Author

ben519 commented Sep 30, 2022

Ah, brilliant. Thank you again.

@squidfunk
Copy link
Owner

Released as part of 8.5.4+insiders-4.24.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