fix: prevent IndexError in focus_index with invalid input #4194
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.
this PR fixes a crash encountered during the installation process when interacting with the TUI menus (specifically in the disk configuration).
the bug:
the
focus_indexmethod inmenu_item.pycurrently attempts to access theenabledlist using a raw index provided by the key press logic. if a user presses a number key (e.g '3') that corresponds to an index larger than the current list size (e.g. in a menu with only 2 items), it raises anIndexErrorand crashes the installer.the fix:
i have added a guard clause to
focus_indexthat checks if the requested index is within valid bounds(0 <= index < len(enabled)). this matches the safety behavior already present infocus_firstandfocus_last.verification:
i reproduced this crash on the latest ISO. i manually patched the file in
/usr/lib/python3.13/site-packages/archinstall/tui/menu_item.pywith this fix, verified that the crash no longer occurs, and successfully completed an installation.Traceback