You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] SelectionList raises OptionDoesNotExist when highlighted index is stale after filtering #6726
SelectionList._on_option_list_option_highlighted can raise an unhandled OptionDoesNotExist when the option_index on the event no longer corresponds to an existing option, e.g. a stale index left over after the option list was filtered or changed.
Real-world impact
This is crashing archinstall's "Additional packages" menu, which uses a filterable SelectionList. If keystrokes arrive while the list is being filtered or the screen is transitioning, the highlight handler gets called with an index that no longer exists. OptionDoesNotExist is raised, and the fallout surfaces further up as a NoMatches exception (No nodes match 'SelectionList' on SelectListScreen()), which takes down the whole installer.
Right now archinstall has to override the Textual handler in its own _SelectionList subclass to stay safe. A fix in Textual would let every app using SelectionList avoid this.
Steps to reproduce
Create a SelectionList with a few options.
Cause a highlight event with an index that is no longer valid (e.g.
filter the options while a highlight is pending, or set highlighted
to an out-of-range index).
get_option_at_index raises OptionDoesNotExist inside the handler.
Minimal reproduction (included as a regression test on the branch below):
A stale highlight event is ignored and no exception is raised.
Proposed fix
Bounds-check event.option_index in _on_option_list_option_highlighted and return early if the option doesn't exist. I have this ready with a regression test and a CHANGELOG entry:
The bug is in SelectionList._on_option_list_option_highlighted — it can raise an unhandled OptionDoesNotExist when the option_index on the event no longer corresponds to an existing option.
I'll add a regression test and fix the root cause.
The bug is in SelectionList._on_option_list_option_highlighted — it can raise an unhandled OptionDoesNotExist when the option_index on the event no longer corresponds to an existing option.
I'll add a regression test and fix the root cause.
Write a better LLM script, my guy. The fix, test and changelog are already attached in my description if you can't see.
src/textual/widgets/_selection_list.py: Added try...except OptionDoesNotExist: handling in _on_option_list_option_highlighted so stale highlight events (e.g. after filtering options or screen transitions) are ignored gracefully.
CHANGELOG.md: Added entry under [Unreleased].
Since PR creation is restricted to repository collaborators, could a maintainer please enable PR access for this branch or pull the fix directly? Thanks
Activity
github-actions commentedon Oct 2, 2026
We found the following entry in the FAQ which you may find helpful:
Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.
This project is developed and maintained by Will McGugan. Consider sponsoring Will's work on this project (and others).
This is an automated reply, generated by FAQtory
DawnofGenX commentedon Oct 4, 2026
I'd like to work on this.
The bug is in
SelectionList._on_option_list_option_highlighted— it can raise an unhandledOptionDoesNotExistwhen theoption_indexon the event no longer corresponds to an existing option.I'll add a regression test and fix the root cause.
hrshtmk commentedon Oct 5, 2026
Write a better LLM script, my guy. The fix, test and changelog are already attached in my description if you can't see.
Guurdeep commentedon Oct 8, 2026
Hi! I've put together the fix along with a unit regression test and CHANGELOG entry on my branch:
https://github.com/Guurdeep/textual/tree/fix/selection-list-bounds
Summary of Changes:
src/textual/widgets/_selection_list.py: Addedtry...except OptionDoesNotExist:handling in_on_option_list_option_highlightedso stale highlight events (e.g. after filtering options or screen transitions) are ignored gracefully.tests/selection_list/test_selection_messages.py: Addedtest_stale_highlight_event_ignored()regression test.CHANGELOG.md: Added entry under[Unreleased].Since PR creation is restricted to repository collaborators, could a maintainer please enable PR access for this branch or pull the fix directly? Thanks
fix(selection_list): ignore stale option_index in option highlighted …