Skip to content

Fix crash when edit_uri is not defined#181

Open
eirikrrrr wants to merge 4 commits intojdoiro3:mainfrom
eirikrrrr:fix/edit-uri-none
Open

Fix crash when edit_uri is not defined#181
eirikrrrr wants to merge 4 commits intojdoiro3:mainfrom
eirikrrrr:fix/edit-uri-none

Conversation

@eirikrrrr
Copy link
Copy Markdown

@eirikrrrr eirikrrrr commented Mar 21, 2026

Summary:
This fixes a crash that occurs when edit_uri is not defined in mkdocs.yml using the multirepo-plugin.

Problem:
DocsRepo._fix_edit_uri assumes 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:

  • Handle None or empty edit_uri safely
  • Remove leftover debug code
  • Add a unit test covering the missing edit_uri case

Validation:

  • Reproduced the failure locally
  • Ran the relevant unit test successfully

Environment

  • OS: Linux
  • Python: 3.9.2
  • Virtual environment: venv
  • MkDocs: <mkdocs, version 1.6.1 from mkdocs-multirepo-plugin/.venv/lib/python3.9/site-packages/mkdocs (Python 3.9)>
  • Plugin under test: local editable install from fork
  • Command used to reproduce:
mkdocs serve -f ../docs-hub/mkdocs.yml -a 0.0.0.0:8000

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


01-test

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


02-test

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 🐈‍⬛

Copilot AI review requested due to automatic review settings March 21, 2026 12:29
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 21, 2026

Version Number Check

Version has been updated in pyproject.toml.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_uri against None/empty values to avoid calling string methods on None.
  • Add a unit test ensuring edit_uri=None normalizes 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.

Comment thread mkdocs_multirepo_plugin/structure.py Outdated
Comment thread tests/unittests.py Outdated
Comment thread mkdocs_multirepo_plugin/structure.py
Eirikr and others added 3 commits March 21, 2026 13:35
deleting trailing-whitespace

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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