{"record":{"id":"bbf6fbcb73066a77","repo":"BerriAI/litellm","slug":"error-updating-policy-in-db-e","errorCode":null,"errorMessage":"Error updating policy in DB: {e}","messagePattern":"Error updating policy in DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":492,"sourceCode":"            if policy_request.guardrails_remove is not None:\n                update_data[\"guardrails_remove\"] = policy_request.guardrails_remove\n            if policy_request.condition is not None:\n                update_data[\"condition\"] = json.dumps(policy_request.condition.model_dump())\n            if policy_request.pipeline is not None:\n                validated_pipeline: Final = GuardrailPipeline(**policy_request.pipeline)\n                update_data[\"pipeline\"] = json.dumps(validated_pipeline.model_dump())\n\n            updated_policy: Final = await _policy_table(prisma_client).update(\n                where={\"policy_id\": policy_id},\n                data=update_data,\n            )\n\n            # Do NOT update in-memory registry: drafts are not loaded into memory.\n\n            return _row_to_policy_db_response(updated_policy)\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error updating policy in DB: %s\", e)\n            raise Exception(f\"Error updating policy in DB: {e}\")\n\n    async def delete_policy_from_db(\n        self,\n        policy_id: str,\n        prisma_client: \"PrismaClient\",\n    ) -> Mapping[str, str]:\n        \"\"\"\n        Delete a policy version from the database.\n\n        If the deleted version was production, it is removed from the in-memory\n        registry. No other version is auto-promoted; admin must explicitly promote.\n\n        Args:\n            policy_id: The ID of the policy version to delete\n            prisma_client: The Prisma client instance\n\n        Returns:\n            Dict with \"message\" and optional \"warning\" if production was deleted.","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L474-L510","documentation":"Catch-all from the policy update routine: building the update payload (including GuardrailPipeline validation and JSON serialization of condition/pipeline) or executing the Prisma update failed; the original exception is embedded in the message.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:492 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB connectivity and logs for the underlying error, then retry the update."],"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"}