{"record":{"id":"f272ff3fa038bee1","repo":"Textualize/textual","slug":"there-is-no-option-with-an-id-of-option-id-r","errorCode":null,"errorMessage":"There is no option with an ID of {option_id!r}","messagePattern":"There is no option with an ID of (.+?)","errorType":"exception","errorClass":"OptionDoesNotExist","httpStatus":null,"severity":"error","filePath":"src/textual/widgets/_option_list.py","lineNumber":444,"sourceCode":"        self.add_options([option])\n        return self\n\n    def get_option(self, option_id: str) -> Option:\n        \"\"\"Get the option with the given ID.\n\n        Args:\n            option_id: The ID of the option to get.\n\n        Returns:\n            The option with the ID.\n\n        Raises:\n            OptionDoesNotExist: If no option has the given ID.\n        \"\"\"\n        try:\n            return self._id_to_option[option_id]\n        except KeyError:\n            raise OptionDoesNotExist(\n                f\"There is no option with an ID of {option_id!r}\"\n            ) from None\n\n    def get_option_index(self, option_id: str) -> int:\n        \"\"\"Get the index (offset in `self.options`) of the option with the given ID.\n\n        Args:\n            option_id: The ID of the option to get the index of.\n\n        Returns:\n            The index of the item with the given ID.\n\n        Raises:\n            OptionDoesNotExist: If no option has the given ID.\n        \"\"\"\n        option = self.get_option(option_id)\n        return self._option_to_index[option]\n","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/widgets/_option_list.py#L426-L462","documentation":"Raised by OptionList.get_option when no option with the supplied id exists. The widget looks up ids in an internal _id_to_option dict built only from Options that were given an explicit id; a KeyError is converted to OptionDoesNotExist.","triggerScenarios":"Calling get_option('missing'), get_option_index('missing'), or remove_option('missing') with an id that was never added (or was removed earlier). Also calling get_option with an option's prompt text instead of its id.","commonSituations":"Stale ids after the option list was rebuilt via set_options/clear_options, typos in ids, or assuming options without explicit ids still have ids (auto options have id None and are not in the map).","solutions":["Check membership first with `option_id in option_list._id_to_option` or wrap in try/except OptionDoesNotExist.","Verify the option was created with an explicit unique id: Option('prompt', id='my-id').","Re-check ids after set_options/clear_options, which invalidate previously valid ids."],"exampleFix":"# before\noption = option_list.get_option(user_choice)\n# after\nfrom textual.widgets.option_list import OptionDoesNotExist\ntry:\n    option = option_list.get_option(user_choice)\nexcept OptionDoesNotExist:\n    option = None","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from textual.widgets.option_list import OptionDoesNotExist\ntry:\n    option = option_list.get_option(option_id)\nexcept OptionDoesNotExist:\n    ...","preventionTips":["Give options explicit ids at creation","Revalidate ids after set_options/clear_options","Wrap lookups driven by user input in try/except OptionDoesNotExist"],"tags":["optionlist","option-not-found","textual"],"backgroundTag":"id-not-found","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}