Skip to content

fix: handle pages without aliases to prevent infinite loops#146

Open
marmionl wants to merge 1 commit intobackstage:masterfrom
marmionl:get-page-dir-alias-fix
Open

fix: handle pages without aliases to prevent infinite loops#146
marmionl wants to merge 1 commit intobackstage:masterfrom
marmionl:get-page-dir-alias-fix

Conversation

@marmionl
Copy link

I cam across this bug when attempting to generate a component that used the sample docs in this repository on my local version of Backstage and it gave the following error:

DEBUG   -  Running `pre_page` event from plugin 'monorepo'
ERROR   -  Error reading page 'index.md': join() missing 1 required positional argument: 'a'
Traceback (most recent call last):
  File "/Users/marmionl/.pyenv/versions/3.11.0/bin/mkdocs", line 7, in <module>
    sys.exit(cli())
             ^^^^^
.
.
.
.
.
  File "/Users/marmionl/.pyenv/versions/3.11.0/lib/python3.11/site-packages/mkdocs_monorepo_plugin/edit_uri.py", line 85, in __get_page_config_file_yaml
    abs_page_config_file_path = self.__get_page_config_file_path()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marmionl/.pyenv/versions/3.11.0/lib/python3.11/site-packages/mkdocs_monorepo_plugin/edit_uri.py", line 53, in __get_page_config_file_path
    alias = self.__get_page_dir_alias()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marmionl/.pyenv/versions/3.11.0/lib/python3.11/site-packages/mkdocs_monorepo_plugin/edit_uri.py", line 37, in __get_page_dir_alias
    alias = path.join(*parts)
            ^^^^^^^^^^^^^^^^^
TypeError: join() missing 1 required positional argument: 'a'

I have changed the loop condition in the __get_page_dir_alias to safely exit when no more path segments remain to check. This allows the method to gracefully return None for pages without aliases instead of crashing.

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.

1 participant