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

Blog plugin fails on standalone setup #5879

Closed
4 tasks done
Andre601 opened this issue Aug 21, 2023 · 14 comments
Closed
4 tasks done

Blog plugin fails on standalone setup #5879

Andre601 opened this issue Aug 21, 2023 · 14 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@Andre601
Copy link
Contributor

Context

No response

Bug description

After updating MkDocs-material from 9.2.0b2 to 9.2.0 today did mkdocs build fail with a stacktrace.
I sadly cannot understand what it points towards nor what it means, but it seems to be related to the blog plugin as commenting it out in the mkdocs.yml builds the site as expected.

Full stacktrace: https://paste.helpch.at/epopumuceb.lua

First I thought this might be an error due to changes to the .authors.yml file which mkdocs-material did report properly, but after fixing those is the issue still persisting.

The documentation is build using Woodpecker-CI by setting up a Python Image (Python 3.11 by the looks of it) and the executing pip install -r requirements.txt followed by mkdocs build. Tho local reproduction tests also show the same errors, so it's unlikely to be bound to the env or software used.

For transparency, here are files and logs related to the failed CI runs:

Related links

Reproduction

mkdocs-2.9.0-build-errors.zip

Steps to reproduce

  1. Download mkdocs-material 2.9.0
  2. Setup mkdocs.yml with bare-bones settings and blog plugin configuration
  3. Create post folder and blog post file
  4. Run mkdocs serve or mkdocs build

Browser

Firefox

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting. Looking into it. Documentation for authors_file format fixed in a313fa9.

@squidfunk squidfunk added the bug Issue reports a bug label Aug 21, 2023
@squidfunk
Copy link
Owner

Fixed in 7099ea6. There were several cases that were not handled. The error reported originated from using the blog plugin on the top-level. The blog plugin was completely rewritten, so it's expected that there are some cases we missed.

Note that you did not define an authors file, which is why the plugin errors and can't find user. If you remove the authors setting or define an authors file, the error is gone.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Aug 21, 2023
@squidfunk
Copy link
Owner

Released as part of 9.2.1.

@Andre601
Copy link
Contributor Author

Fixed in 7099ea6. There were several cases that were not handled. The error reported originated from using the blog plugin on the top-level. The blog plugin was completely rewritten, so it's expected that there are some cases we missed.

Note that you did not define an authors file, which is why the plugin errors and can't find user. If you remove the authors setting or define an authors file, the error is gone.

That's kinda strange... I have a .authors.yml file in the docs directory from the beta which worked back then, so I guess that behaviour changed too?
Since my blog_dir is the docs dir itself, should the file remain there?
It's currently looking like this: https://codeberg.org/Andre601/blog-source/src/branch/master/docs/.authors.yml

@Andre601
Copy link
Contributor Author

@vedranmiletic
Copy link
Contributor

I get a different error from @Andre601:

Traceback (most recent call last):
  File "/home/vedranmiletic/software/mkdocs-venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/__main__.py", line 283, in build_command
    cfg = config.load_config(**kwargs)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/base.py", line 378, in load_config
    errors, warnings = cfg.validate()
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/base.py", line 230, in validate
    run_failed, run_warnings = self._validate()
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/base.py", line 188, in _validate
    self[key] = config_option.validate(value)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 182, in validate
    return self.run_validation(value)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 1064, in run_validation
    self.load_plugin_with_namespace(name, cfg)
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 1100, in load_plugin_with_namespace
    return (name, self.load_plugin(name, config))
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 1118, in load_plugin
    plugin_cls = self.installed_plugins[name].load()
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 209, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 44, in <module>
    from .structure import Archive, Category, Excerpt, Post, View
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/material/plugins/blog/structure/__init__.py", line 203, in <module>
    class View(Page):
  File "/home/vedranmiletic/software/mkdocs-venv/lib/python3.9/site-packages/material/plugins/blog/structure/__init__.py", line 206, in View
    def __init__(self, title: str | None, file: File, config: MkDocsConfig):
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

The new or old structure of .authors.yml doesn't make any difference. Should I try to create a minimal example?

@squidfunk
Copy link
Owner

@Andre601 this looks like a different error, probably like #5880.

@vedranmiletic Yes, we definitely need a minimal reproduction, so please create a new issue.

@squidfunk
Copy link
Owner

squidfunk commented Aug 22, 2023

That's kinda strange... I have a .authors.yml file in the docs directory from the beta which worked back then, so I guess that behaviour changed too?

The reproduction did not contain a file called .authors.yml, probably because the info plugin did not add it as it's a hidden file. Thus this might be a bug (or undesired behavior) in the info plugin.

@squidfunk squidfunk changed the title Blog plugin causes mkdocs build fail for mkdocs-material 2.9.0 Blog plugin fails on standalone setup Aug 22, 2023
@vedranmiletic
Copy link
Contributor

@squidfunk thanks! Done in #5881.

@squidfunk
Copy link
Owner

I've checked whether the info plugin omits files – it packs everything that is in the docs_dir. Thus, the .authors.yml file was likely not defined, or I'm not sure why it was missing from the archive:

  example/docs/.authors.yml 13.0 B
  example/docs/.overrides/extra.js 2.0 B
  example/docs/index.md 282.0 B
  example/docs/posts/some/other/path/post-2.md 2.0 B
  example/docs/posts/post-1.md 2.0 B
  example/mkdocs.yml 93.0 B
  example/platform.json 61.0 B
  example/requirements.lock.txt 390.0 B

  example.zip 2.2 kB

@Andre601
Copy link
Contributor Author

I may have missed a setup step in the minimal reproduction as I made a bare-bones setup. But I can guarantee (As shown by the shared links) that the repo this appears on actually has a .authors.yml file present.

I'll double check the repro setup and see if I missed the authors file.

@Andre601
Copy link
Contributor Author

On a unrelated note: The info plugin seems to handle the name you give a bit differently when providing dots in the name. As an example my last zip generated by it was named mkdocs-29.zip iirc

It's obviously not that big of a deal. Just something I found worth pointing out.

@Andre601
Copy link
Contributor Author

Alright. The .authors.yml file was indeed missing.

Adding it makes the serve and build command work fine on my Desktop. Tho, that makes the cause of the CI failing even more confusing given the Authors file is present.

@Andre601
Copy link
Contributor Author

Want to quickly mention that the build now works on the CI using 2.9.3, so there probably was a fix for that too. Thanks

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

3 participants