Fix crash when edit_uri is not defined#181
Open
eirikrrrr wants to merge 4 commits intojdoiro3:mainfrom
Open
Conversation
Version Number CheckVersion has been updated in pyproject.toml. |
There was a problem hiding this comment.
Pull request overview
Fixes a MkDocs crash in the multirepo plugin when edit_uri is unset (None) by making DocsRepo._fix_edit_uri defensive, and adds a regression unit test to cover the scenario.
Changes:
- Guard
DocsRepo._fix_edit_uriagainstNone/empty values to avoid calling string methods onNone. - Add a unit test ensuring
edit_uri=Nonenormalizes to an empty string.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
mkdocs_multirepo_plugin/structure.py |
Makes edit_uri normalization resilient to missing values. |
tests/unittests.py |
Adds regression coverage for edit_uri=None input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
deleting trailing-whitespace Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This fixes a crash that occurs when edit_uri is not defined in mkdocs.yml using the multirepo-plugin.
Problem:
DocsRepo._fix_edit_uriassumes edit_uri is always a string and calls strip() on it.When edit_uri is None, MkDocs fails with:
AttributeError: 'NoneType' object has no attribute 'strip'
Reproduction:
Run mkdocs serve with a config that uses the plugin and does not define edit_uri.
Fix:
Validation:
Environment
venv<mkdocs, version 1.6.1 from mkdocs-multirepo-plugin/.venv/lib/python3.9/site-packages/mkdocs (Python 3.9)>References
There is prior context in this repository around related edit_uri and import behavior:
issues/84
pull/75
This PR builds on that context by handling missing edit_uri defensively to avoid runtime crashes.
Images
I did a clean installation of mkdocs in a virtual environment with python3.9 and when running my YAML with the edit_uri configuration mentioned, the error appears for the first time.
If I activate the edit_uri field the error disappears and my repositories load normally
Note: This is my first time contributing to open source, and I apologize in advance if the PR or issue format is not the expected one. I looked for documentation about the preferred format for PRs and issues, but I could not find any 🐈⬛