{"record":{"id":"6ffa592a578fe84a","repo":"home-assistant/core","slug":"backup-backup-id-not-found","errorCode":null,"errorMessage":"Backup {backup_id} not found","messagePattern":"Backup (.+?) not found","errorType":"exception","errorClass":"BackupNotFound","httpStatus":null,"severity":"warning","filePath":"homeassistant/components/aws_s3/backup.py","lineNumber":342,"sourceCode":"        return list(backups.values())\n\n    @handle_boto_errors\n    @override\n    async def async_get_backup(\n        self,\n        backup_id: str,\n        **kwargs: Any,\n    ) -> AgentBackup:\n        \"\"\"Return a backup.\"\"\"\n        return await self._find_backup_by_id(backup_id)\n\n    async def _find_backup_by_id(self, backup_id: str) -> AgentBackup:\n        \"\"\"Find a backup by its backup ID.\"\"\"\n        backups = await self._list_backups()\n        if backup := backups.get(backup_id):\n            return backup\n\n        raise BackupNotFound(f\"Backup {backup_id} not found\")\n\n    async def _list_backups(self) -> dict[str, AgentBackup]:\n        \"\"\"List backups, using a cache if possible.\"\"\"\n        if time() <= self._cache_expiration:\n            return self._backup_cache\n\n        backups_list = await async_list_backups_from_s3(\n            self._client, self._bucket, self._prefix\n        )\n        self._backup_cache = {b.backup_id: b for b in backups_list}\n        self._cache_expiration = time() + CACHE_TTL\n\n        return self._backup_cache\n","sourceCodeStart":324,"sourceCodeEnd":356,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/aws_s3/backup.py#L324-L356","documentation":"Raised as BackupNotFound(f'Backup {backup_id} not found') by S3BackupAgent._find_backup_by_id when the requested backup_id is not present in the (possibly cached) listing of backups in the S3 bucket. Home Assistant's backup manager uses this to know the agent cannot serve that backup for download or delete.","triggerScenarios":"Calling async_get_backup or delete with a backup_id that is not a key in _list_backups(): backup was deleted from S3 directly, the prefix/bucket in the config entry changed, the listing cache predates a remote deletion, or the metadata object for that backup is missing/corrupt.","commonSituations":"User manually cleaned the S3 bucket; config entry's prefix changed so old backups are no longer listed; bucket lifecycle rules expired objects; cache TTL (CACHE_TTL) masking a very recent external deletion.","solutions":["Confirm the backup still exists in S3 under the configured bucket and prefix (aws s3 ls or console).","If the prefix/bucket changed, re-point the config entry or move objects back under the expected prefix.","Check bucket lifecycle/expiration rules aren't deleting backups.","Note the listing may be cached for CACHE_TTL seconds — re-check after the cache expires."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"backups = await agent._list_backups()\nif backup_id not in backups:\n    skip_local_delete(backup_id)  # avoid BackupNotFound on delete/download","typeGuard":"async def backup_exists(agent, backup_id: str) -> bool:\n    backups = await agent._list_backups()\n    return backup_id in backups\n","tryCatchPattern":"from homeassistant.components.backup import BackupNotFound\n\ntry:\n    await agent.async_get_backup(backup_id)\nexcept BackupNotFound:\n    # treat as already removed; safe to skip in delete/download flows\n    pass","preventionTips":["Check membership in the listing before acting on a backup_id.","Keep bucket/prefix stable so previously written backups stay discoverable.","Remember listing results are cached for CACHE_TTL seconds after external changes."],"tags":["home-assistant","aws","s3","backup","not-found"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}