{"record":{"id":"45c9f45a1253dbb6","repo":"BerriAI/litellm","slug":"error-adding-policy-to-db-e","errorCode":null,"errorMessage":"Error adding policy to DB: {e}","messagePattern":"Error adding policy to DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":428,"sourceCode":"            policy: Final = self._parse_policy(\n                policy_request.policy_name,\n                {\n                    \"inherit\": policy_request.inherit,\n                    \"description\": policy_request.description,\n                    \"guardrails\": {\n                        \"add\": policy_request.guardrails_add,\n                        \"remove\": policy_request.guardrails_remove,\n                    },\n                    \"condition\": (policy_request.condition.model_dump() if policy_request.condition else None),\n                    \"pipeline\": policy_request.pipeline,\n                },\n            )\n            self.add_policy(policy_request.policy_name, policy)\n\n            return _row_to_policy_db_response(created_policy)\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error adding policy to DB: %s\", e)\n            raise Exception(f\"Error adding policy to DB: {e}\")\n\n    async def update_policy_in_db(\n        self,\n        policy_id: str,\n        policy_request: PolicyUpdateRequest,\n        prisma_client: \"PrismaClient\",\n        updated_by: str | None = None,\n    ) -> PolicyDBResponse:\n        \"\"\"\n        Update a policy in the database. Only draft versions can be updated.\n\n        Args:\n            policy_id: The ID of the policy to update\n            policy_request: The policy update request\n            prisma_client: The Prisma client instance\n            updated_by: User who updated the policy\n\n        Returns:","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L410-L446","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:428 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB connectivity and the error detail; resolve constraint violations (e.g. duplicate name) and retry."],"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"}