{"record":{"id":"fca37eb554a71144","repo":"BerriAI/litellm","slug":"error-deleting-policy-from-db-e","errorCode":null,"errorMessage":"Error deleting policy from DB: {e}","messagePattern":"Error deleting policy from DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":542,"sourceCode":"            result: Final[dict[str, str]] = {\"message\": f\"Policy {policy_id} deleted successfully\"}\n\n            # Remove from in-memory registry only if this was the production version\n            if version_status == \"production\":\n                self.remove_policy(policy_name)\n                if self.get_source(policy_name) == \"config\":\n                    result[\"warning\"] = (\n                        \"Production version was deleted. The config-defined policy with the same name is active again.\"\n                    )\n                else:\n                    result[\"warning\"] = (\n                        \"Production version was deleted. No other version was promoted. \"\n                        \"Promote another version to production if this policy should remain active.\"\n                    )\n\n            return result\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error deleting policy from DB: %s\", e)\n            raise Exception(f\"Error deleting policy from DB: {e}\")\n\n    async def get_policy_by_id_from_db(\n        self,\n        policy_id: str,\n        prisma_client: \"PrismaClient\",\n    ) -> PolicyDBResponse | None:\n        \"\"\"\n        Get a policy by ID from the database.\n\n        Args:\n            policy_id: The ID of the policy to retrieve\n            prisma_client: The Prisma client instance\n\n        Returns:\n            PolicyDBResponse if found, None otherwise\n        \"\"\"\n        try:\n            policy: Final = await _policy_table(prisma_client).find_unique(where={\"policy_id\": policy_id})","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L524-L560","documentation":"Catch-all from the policy delete routine: the Prisma delete of the policy row (or the follow-up in-memory registry maintenance) raised; the original error text is included. Any produced warnings about config-defined takeover are lost when this raises.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:542 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB connectivity and logs; ensure no references block deletion, then 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"}