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

When a Markdown extension fails to load, print its name and traceback #2894

Merged
merged 2 commits into from
Jul 19, 2022

Conversation

oprypin
Copy link
Contributor

@oprypin oprypin commented Jul 18, 2022

No description provided.

@oprypin
Copy link
Contributor Author

oprypin commented Jul 18, 2022

Example output:

ERROR    -  Config value: 'markdown_extensions'. Error: Failed to load extension 'mdx_gh_links'.
              File "/home/blaxpirit/repos/mkdocs/venv/lib/python3.10/site-packages/mdx_gh_links.py", line 35, in <module>
                from markdown.util import etree
            ImportError: cannot import name 'etree' from 'markdown.util' (/home/blaxpirit/.local/lib/py/markdown/util.py)
Aborted with 1 Configuration Errors!

@ultrabug
Copy link
Member

Thanks, the PR is good as-is

I was just wondering if we should add a mention that makes it explicit that mkdocs is not responsible for the breakage, like Please check the traceback below to find out which extension module has a problem and report to them.

@oprypin
Copy link
Contributor Author

oprypin commented Jul 19, 2022

Actually we don't know that that's true - that the extension is at fault. This could also be coming from configuring the extension incorrectly.

extensions:
  - pymdownx.superfences:
      custom_fences: foo
ERROR    -  Config value: 'markdown_extensions'. Error: Failed to load extension 'pymdownx.superfences'.
              File "/home/blaxpirit/repos/mkdocs/mkdocs/config/config_options.py", line 641, in run_validation
                md.registerExtensions((ext,), self.configdata)
              File "/home/blaxpirit/repos/mkdocs/venv/lib/python3.10/site-packages/markdown/core.py", line 125, in registerExtensions
                ext.extendMarkdown(self)
              File "/home/blaxpirit/repos/mkdocs/venv/lib/python3.10/site-packages/pymdownx/superfences.py", line 273, in extendMarkdown
                name = custom.get('name')
            AttributeError: 'str' object has no attribute 'get'

Previously it was just this, btw:

ERROR    -  Config value: 'markdown_extensions'. Error: 'str' object has no attribute 'get'

Determining that this is for sure an extension's fault could be more complex or not even feasible.

@oprypin oprypin merged commit 6bd62b9 into mkdocs:master Jul 19, 2022
ultrabug added a commit to ultrabug/mkdocs that referenced this pull request Jul 25, 2022
ultrabug added a commit to ultrabug/mkdocs that referenced this pull request Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants