BerriAI/litellm · error · Exception
Error adding policy to DB: {e}
Error message
Error adding policy to DB: {e} What it means
Catch-all from PolicyRegistry.add_policy_to_db: parsing the policy request or inserting the row into the policy table failed (validation of pipeline/condition serialization, or a Prisma write error). The original exception is chained into the message.
Source
Thrown at litellm/proxy/policy_engine/policy_registry.py:428
policy: Final = self._parse_policy(
policy_request.policy_name,
{
"inherit": policy_request.inherit,
"description": policy_request.description,
"guardrails": {
"add": policy_request.guardrails_add,
"remove": policy_request.guardrails_remove,
},
"condition": (policy_request.condition.model_dump() if policy_request.condition else None),
"pipeline": policy_request.pipeline,
},
)
self.add_policy(policy_request.policy_name, policy)
return _row_to_policy_db_response(created_policy)
except Exception as e:
verbose_proxy_logger.exception("Error adding policy to DB: %s", e)
raise Exception(f"Error adding policy to DB: {e}")
async def update_policy_in_db(
self,
policy_id: str,
policy_request: PolicyUpdateRequest,
prisma_client: "PrismaClient",
updated_by: str | None = None,
) -> PolicyDBResponse:
"""
Update a policy in the database. Only draft versions can be updated.
Args:
policy_id: The ID of the policy to update
policy_request: The policy update request
prisma_client: The Prisma client instance
updated_by: User who updated the policy
Returns:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Check DB connectivity and the error detail; resolve constraint violations (e.g. duplicate name) and retry.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:428 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/45c9f45a1253dbb6.
Report an issue: GitHub.