fix: prevent IndexError in focus_index with invalid input#4194
Open
projectakshith wants to merge 1 commit intoarchlinux:masterfrom
Open
fix: prevent IndexError in focus_index with invalid input#4194projectakshith wants to merge 1 commit intoarchlinux:masterfrom
projectakshith wants to merge 1 commit intoarchlinux:masterfrom
Conversation
Prevents crash when pressing number keys (e.g. '3') in menus with fewer items.
Collaborator
|
The menu has been rewritten to use textual and this is no longer used on master. |
Author
|
i think it is worth keeping, i mean having a secondary method to navigate will always be better for accessibility. if for some reason the arrow keys aren't convenient, or they get mangled in web consoles or certain remote setups (where escape codes don't pass through correctly), number keys could be a reliable fallback that the users could still use imo |
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.
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