{"record":{"id":"768ba937c3cd14b6","repo":"home-assistant/core","slug":"could-not-find-to-do-item-uid","errorCode":null,"errorMessage":"Could not find To-do item {uid}","messagePattern":"Could not find To-do item (.+?)","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/caldav/todo.py","lineNumber":155,"sourceCode":"        try:\n            await self.hass.async_add_executor_job(\n                partial(self._calendar.save_todo, **item_data),\n            )\n            # refreshing async otherwise it would take too much time\n            self.hass.async_create_task(self.async_update_ha_state(force_refresh=True))\n        except (requests.ConnectionError, requests.Timeout, DAVError) as err:\n            raise HomeAssistantError(f\"CalDAV save error: {err}\") from err\n\n    @override\n    async def async_update_todo_item(self, item: TodoItem) -> None:\n        \"\"\"Update a To-do item.\"\"\"\n        uid: str = cast(str, item.uid)\n        try:\n            todo = await self.hass.async_add_executor_job(\n                self._calendar.todo_by_uid, uid\n            )\n        except NotFoundError as err:\n            raise HomeAssistantError(f\"Could not find To-do item {uid}\") from err\n        except (requests.ConnectionError, requests.Timeout, DAVError) as err:\n            raise HomeAssistantError(f\"CalDAV lookup error: {err}\") from err\n        vtodo = todo.icalendar_component  # type: ignore[attr-defined]\n        vtodo[\"SUMMARY\"] = item.summary or \"\"\n        if status := item.status:\n            vtodo[\"STATUS\"] = TODO_STATUS_MAP_INV.get(status, \"NEEDS-ACTION\")\n        if due := item.due:\n            todo.set_due(due)  # type: ignore[attr-defined]\n        else:\n            vtodo.pop(\"DUE\", None)\n        if description := item.description:\n            vtodo[\"DESCRIPTION\"] = description\n        else:\n            vtodo.pop(\"DESCRIPTION\", None)\n        try:\n            await self.hass.async_add_executor_job(\n                partial(\n                    todo.save,","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/caldav/todo.py#L137-L173","documentation":"HomeAssistantError raised in async_update_todo_item when todo_by_uid raises NotFoundError — the server has no VTODO with the given UID. Usually the item was deleted server-side (or from another client) after the HA list was last refreshed.","triggerScenarios":"Calling todo.update_item with a uid that no longer exists on the CalDAV server: concurrent modification, deletion in the native calendar app, or a stale local cache after the server pruned old completed items.","commonSituations":"User deletes a task on their phone while HA still shows it; servers auto-purging completed tasks; calendar shared and edited by multiple clients.","solutions":["Refresh the to-do list entity (call todo/get_items or wait for the next coordinator update) and retry against an existing uid","Delete and recreate the item if the update is important and the original is gone server-side","Check the server-side trash/auto-purge settings if items keep disappearing unexpectedly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"uid = item.uid\nitems = {t.uid for t in (self.coordinator.data.items if self.coordinator.data else [])}\nif uid not in items:\n    # refresh or skip instead of hitting NotFoundError","typeGuard":null,"tryCatchPattern":"except NotFoundError as err:\n    raise HomeAssistantError(f\"Could not find To-do item {uid}\") from err","preventionTips":["Refresh the entity before updates triggered from long-lived automations","Resolve uids via todo.get_items at runtime instead of hardcoding","Treat NotFoundError as an idempotency signal (item already gone) where safe"],"tags":["homeassistant","caldav","todo","not-found","stale-state"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}