{"record":{"id":"5b911454266ec90e","repo":"BerriAI/litellm","slug":"error-adding-attachment-to-db-e","errorCode":null,"errorMessage":"Error adding attachment to DB: {e}","messagePattern":"Error adding attachment to DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":500,"severity":"error","filePath":"litellm/proxy/policy_engine/attachment_registry.py","lineNumber":335,"sourceCode":"            )\n            self.add_attachment(attachment)\n\n            return PolicyAttachmentDBResponse(\n                attachment_id=created_attachment.attachment_id,\n                policy_name=created_attachment.policy_name,\n                scope=created_attachment.scope,\n                teams=created_attachment.teams or [],\n                keys=created_attachment.keys or [],\n                models=created_attachment.models or [],\n                tags=created_attachment.tags or [],\n                created_at=created_attachment.created_at,\n                updated_at=created_attachment.updated_at,\n                created_by=created_attachment.created_by,\n                updated_by=created_attachment.updated_by,\n            )\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error adding attachment to DB: %s\", e)\n            raise Exception(f\"Error adding attachment to DB: {e}\")\n\n    async def delete_attachment_from_db(\n        self,\n        attachment_id: str,\n        prisma_client: \"PrismaClient\",\n    ) -> 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","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/attachment_registry.py#L317-L353","documentation":"DB error wrapper in the policy attachment registry: creating the attachment row in Prisma raised (constraint violation, connection loss, etc.). The original exception is logged and re-raised with this prefix after the in-memory rollback.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/attachment_registry.py:335 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and the error detail; ensure the attachments table exists (run migrations).","Retry the request; if a unique constraint fired, choose a different attachment name/ID."],"exampleFix":null,"handlingStrategy":"try-catch","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-14T05:17:10.506Z"}