BerriAI/litellm · error · Exception
Error deleting attachment from DB: {e}
Error message
Error deleting attachment from DB: {e} What it means
Catch-all error from the policy attachment delete routine: a non-lookup failure (typically a Prisma/database error during find_unique or delete on the policy attachment table) was raised while deleting the attachment; the original exception is embedded in the message.
Source
Thrown at litellm/proxy/policy_engine/attachment_registry.py:371
# Get attachment before deleting
attachment: Final[LiteLLM_PolicyAttachmentTable | None] = await PolicyAttachmentRepository(
prisma_client
).table.find_unique(where={"attachment_id": attachment_id})
if attachment is None:
raise Exception(f"Attachment with ID {attachment_id} not found")
# Delete from DB
await PolicyAttachmentRepository(prisma_client).table.delete(where={"attachment_id": attachment_id})
# Note: In-memory attachments don't have IDs, so we need to sync from DB
# to properly update in-memory state
await self.sync_attachments_from_db(prisma_client)
return {"message": f"Attachment {attachment_id} deleted successfully"}
except Exception as e:
verbose_proxy_logger.exception("Error deleting attachment from DB: %s", e)
raise Exception(f"Error deleting attachment from DB: {e}")
async def get_attachment_by_id_from_db(
self,
attachment_id: str,
prisma_client: "PrismaClient",
) -> PolicyAttachmentDBResponse | None:
"""
Get a policy attachment by ID from the database.
Args:
attachment_id: The ID of the attachment to retrieve
prisma_client: The Prisma client instance
Returns:
PolicyAttachmentDBResponse if found, None otherwise
"""
try:
attachment: Final[LiteLLM_PolicyAttachmentTable | None] = await PolicyAttachmentRepository(View on GitHub (pinned to 77b7c6c40c)
Solutions
- Check database connectivity and logs for the underlying DB error, then retry the delete.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/proxy/policy_engine/attachment_registry.py:371 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/f043d6a336db3322.
Report an issue: GitHub.