fix: handle empty URL parts in edit_uri to prevent TypeError#149
Open
suraj-aleph wants to merge 1 commit intobackstage:masterfrom
Open
fix: handle empty URL parts in edit_uri to prevent TypeError#149suraj-aleph wants to merge 1 commit intobackstage:masterfrom
suraj-aleph wants to merge 1 commit intobackstage:masterfrom
Conversation
`__get_page_dir_alias` crashes with `TypeError: join() missing 1 required positional argument` when processing root-level pages (e.g. `index.md`). The page URL splits into parts that become empty after popping, and `path.join(*parts)` fails on an empty list. Guard the loop to terminate when parts is exhausted, and return None when no alias matches. In `build()`, fall back to the page's default edit_url when no alias is found. Fixes backstage#131 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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
Fixes a
TypeErrorcrash inedit_uri.pywhen the monorepo plugin processes root-level pages (e.g.index.md).Problem
__get_page_dir_aliassplitspage.urlby/and pops parts in awhile Trueloop until it finds a matching alias. For root-level pages the URL is empty or has no directory component, sopartsbecomes an empty list — andpath.join(*parts)raises:Full traceback:
This affects any project using the monorepo plugin with root-level pages in the main
docs/directory alongside!included sub-projects.Fix
Two changes in
edit_uri.py:__get_page_dir_alias: Replace thewhile Trueloop withwhile partsso it terminates safely. Usepath.join(*parts) if parts else ""to handle the final iteration. ReturnNonewhen no alias matches instead of looping into a crash.build: When__get_page_dir_alias()returnsNone(page doesn't belong to any included sub-project), fall back to the page's defaultedit_urlinstead of proceeding to methods that wouldKeyErroron aNonealias.Related
Fixes #131
🤖 Generated with Claude Code