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

Tags plugin: sometimes crashes on empty tags #7097

Closed
4 tasks done
godotc opened this issue Apr 24, 2024 · 3 comments
Closed
4 tasks done

Tags plugin: sometimes crashes on empty tags #7097

godotc opened this issue Apr 24, 2024 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@godotc
Copy link
Contributor

godotc commented Apr 24, 2024

Context

I'm migrating my docs repo. And was tried to use mkdocs with material theme to build blog somewhat. I use obsidian as the editor. And the default metadata's tags will be empty. Also that I level it empty in most files.
Which looks like:

Author: "@godot42"
Date: "{{date}} {{time}}"
pub: false
pub-category:
tags:

But as I enabled the tags plugin, empty tags section will be considered as a exception.

Bug description

The error messages and traceback:
ERROR - Error building page 'Arc/Game/ECS_With_UI.md': 'NoneType' object is not iterable
Traceback (most recent call last):
File "C:\Users\norm\miniconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\norm\miniconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\norm\miniconda3\Scripts\mkdocs.exe_main
.py", line 7, in
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 783, in invoke
return _callback(*args, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs_main
.py", line 270, in serve_command
serve.serve(**kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\serve.py", line 86, in serve
builder(config)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\serve.py", line 67, in builder
build(config, live_server=None if is_clean else server, dirty=is_dirty)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\build.py", line 349, in build
_build_page(
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\build.py", line 222, in _build_page
context = config.plugins.on_page_context(context, page=page, config=config, nav=nav)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\plugins.py", line 583, in on_page_context
return self.run_event('page_context', context, page=page, config=config, nav=nav)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\plugins.py", line 507, in run_event
result = method(item, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\material\plugins\tags\plugin.py", line 117, in on_page_context
context["tags"] = [
TypeError: 'NoneType' object is not iterable

Related links

Reproduction

9.5.18-tags_plugins_exception.zip

Steps to reproduce

Run mkdocs when tags of metadata is empty

Browser

No response

Before submitting

@godotc
Copy link
Contributor Author

godotc commented Apr 24, 2024

Hello! I noticed that many of my notes currently have empty tags in the metadata section. Are these empty tags considered valid for mkdocs?
I just encountered an exception in the source code related to this when I execute build/serve process to create a blog. And the exception which I've already addressed by making modifications and testing them thoroughly.
Everything seems to be working smoothly now (just made a simple test)🎉🎉! Or are there any spec considerations I might have overlooked?
I have just gone ahead and created a pull request for this issue: #7098.

@squidfunk
Copy link
Owner

Thanks for reporting and creating the PR! I've ran your reproduction, and can't observe the problem. However, looking at the code, your proposed changes definitely make sense to better safe guard against such errors, and I can't rule out that it might be related to some other version of some other package that is causing the problem.

@squidfunk squidfunk changed the title tags plugin | Exception when zero tags in tags section of markdown's meta data when tags plugin enabled. Tags plugin: sometimes crashes on empty tags Apr 25, 2024
@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open labels Apr 25, 2024
@squidfunk
Copy link
Owner

Released as part of 9.5.19

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