BerriAI/litellm · error · Exception
Attachment with ID not found
Error message
Attachment with ID {attachment_id} not found What it means
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).
Solutions
- List attachments to confirm the ID; the attachment may have been deleted.
- Recreate the attachment if needed.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at litellm/proxy/policy_engine/attachment_registry.py:359 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/e09f84a37e8d7b48.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/proxy/policy_engine/attachment_registry.py:359
) -> dict[str, str]:
"""
Delete a policy attachment from the database.
Args:
attachment_id: The ID of the attachment to delete
prisma_client: The Prisma client instance
Returns:
Dict with success message
"""
try:
# 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:View on GitHub (pinned to 77b7c6c40c)