{"record":{"id":"ed91bdbb55ca65c7","repo":"home-assistant/core","slug":"subentry-not-found","errorCode":null,"errorMessage":"subentry_not_found","messagePattern":"subentry_not_found","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"warning","filePath":"homeassistant/components/anthropic/repairs.py","lineNumber":180,"sourceCode":"\n            self._current_entry_id = entry_id\n            self._current_subentry_id = subentry_id\n            return entry, subentry, model\n\n    def _async_update_current_subentry(self, user_input: dict[str, str]) -> None:\n        \"\"\"Update the currently selected subentry.\"\"\"\n        if (\n            self._current_entry_id is None\n            or self._current_subentry_id is None\n            or (\n                entry := self.hass.config_entries.async_get_entry(\n                    self._current_entry_id\n                )\n            )\n            is None\n            or (subentry := entry.subentries.get(self._current_subentry_id)) is None\n        ):\n            raise HomeAssistantError(\n                translation_domain=DOMAIN, translation_key=\"subentry_not_found\"\n            )\n\n        updated_data = {\n            **subentry.data,\n            CONF_CHAT_MODEL: user_input[CONF_CHAT_MODEL],\n        }\n        self.hass.config_entries.async_update_subentry(\n            entry,\n            subentry,\n            data=updated_data,\n        )\n\n    def _format_subentry_type(self, subentry_type: str) -> str:\n        \"\"\"Return a user-friendly subentry type label.\"\"\"\n        if subentry_type == \"conversation\":\n            return \"Conversation agent\"\n        if subentry_type in (\"ai_task\", \"ai_task_data\"):","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/anthropic/repairs.py#L162-L198","documentation":"A HomeAssistantError with translation key 'subentry_not_found' raised in the Anthropic repairs flow's update handler when the stored entry id or subentry id no longer resolves: async_get_entry returns None, the entry has no such subentry, or either id was never set. It protects async_update_subentry from operating on stale state.","triggerScenarios":"User opens a repair flow for a deprecated model subentry, but the config entry or subentry is deleted (or the flow state reset) before submitting the form — self._current_entry_id/_current_subentry_id then dangle.","commonSituations":"Repair dialog left open while the user (or another session) deletes the assistant config entry; multiple repair flows racing on the same subentry; browser back/forward resubmitting a stale form.","solutions":["Dismiss the stale repair dialog and re-open the repair from the Repairs panel against an entry that still exists","Verify the config entry and its subentries still exist under Settings > Devices & Services before submitting","Restart the repair flow if the entry was recreated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def subentry_alive(hass, entry_id: str | None, subentry_id: str | None) -> bool:\n    if entry_id is None or subentry_id is None:\n        return False\n    entry = hass.config_entries.async_get_entry(entry_id)\n    return entry is not None and subentry_id in entry.subentries","typeGuard":null,"tryCatchPattern":"if self._current_entry_id is None or self._current_subentry_id is None or (entry := ...) is None or (subentry := ...) is None:\n    raise HomeAssistantError(translation_domain=DOMAIN, translation_key=\"subentry_not_found\")","preventionTips":["Re-check entry/subentry existence at submit time, not only when the flow step is shown","Close repair dialogs before deleting the related config entry"],"tags":["home-assistant","anthropic","repairs","subentry","stale-state"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}