{"record":{"id":"e09f84a37e8d7b48","repo":"BerriAI/litellm","slug":"attachment-with-id-attachment-id-not-found","errorCode":null,"errorMessage":"Attachment with ID {attachment_id} not found","messagePattern":"Attachment with ID (.+?) not found","errorType":"exception","errorClass":"Exception","httpStatus":500,"severity":"error","filePath":"litellm/proxy/policy_engine/attachment_registry.py","lineNumber":359,"sourceCode":"    ) -> dict[str, str]:\n        \"\"\"\n        Delete a policy attachment from the database.\n\n        Args:\n            attachment_id: The ID of the attachment to delete\n            prisma_client: The Prisma client instance\n\n        Returns:\n            Dict with success message\n        \"\"\"\n        try:\n            # Get attachment before deleting\n            attachment: Final[LiteLLM_PolicyAttachmentTable | None] = await PolicyAttachmentRepository(\n                prisma_client\n            ).table.find_unique(where={\"attachment_id\": attachment_id})\n\n            if attachment is None:\n                raise Exception(f\"Attachment with ID {attachment_id} not found\")\n\n            # Delete from DB\n            await PolicyAttachmentRepository(prisma_client).table.delete(where={\"attachment_id\": attachment_id})\n\n            # Note: In-memory attachments don't have IDs, so we need to sync from DB\n            # to properly update in-memory state\n            await self.sync_attachments_from_db(prisma_client)\n\n            return {\"message\": f\"Attachment {attachment_id} deleted successfully\"}\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error deleting attachment from DB: %s\", e)\n            raise Exception(f\"Error deleting attachment from DB: {e}\")\n\n    async def get_attachment_by_id_from_db(\n        self,\n        attachment_id: str,\n        prisma_client: \"PrismaClient\",\n    ) -> PolicyAttachmentDBResponse | None:","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/attachment_registry.py#L341-L377","documentation":"Policy attachment deletion guard: the lookup by attachment_id in the PolicyAttachment table returned no row, so the attachment the caller asked to delete does not exist (already deleted, wrong ID, or different tenant scope).","triggerScenarios":"Thrown at litellm/proxy/policy_engine/attachment_registry.py:359 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["List attachments to confirm the ID; the attachment may have been deleted.","Recreate the attachment if needed."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}