{"record":{"id":"71fb06c6da5f3c4b","repo":"BerriAI/litellm","slug":"error-getting-policies-from-db-e","errorCode":null,"errorMessage":"Error getting policies from DB: {e}","messagePattern":"Error getting policies from DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":615,"sourceCode":"                           (\"draft\", \"published\", \"production\").\n\n        Returns:\n            List of PolicyDBResponse objects\n        \"\"\"\n        try:\n            where: Final[dict[str, str]] = {}\n            if version_status is not None:\n                where[\"version_status\"] = version_status\n\n            policies: Final = await _policy_table(prisma_client).find_many(\n                where=where if where else None,\n                order={\"created_at\": \"desc\"},\n            )\n\n            return [_row_to_policy_db_response(p) for p in policies]\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error getting policies from DB: %s\", e)\n            raise Exception(f\"Error getting policies from DB: {e}\")\n\n    async def sync_policies_from_db(\n        self,\n        prisma_client: \"PrismaClient\",\n    ) -> None:\n        \"\"\"\n        Sync policies from the database to in-memory registry.\n        - Production versions are loaded into _policies (by policy name) for resolution.\n        - Config-loaded policies are preserved; on a name conflict the DB version wins.\n        - Draft and published versions are loaded into _policies_by_id so request-body\n          policy_<uuid> overrides can be resolved without DB access in the hot path.\n        \"\"\"\n        try:\n            production: Final = await self.get_all_policies_from_db(prisma_client, version_status=\"production\")\n            db_policies: Final = {\n                policy_response.policy_name: self._parse_policy(\n                    policy_response.policy_name,\n                    {","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L597-L633","documentation":"Catch-all from the policy list routine: the find_many query on the policy table (optionally filtered by version_status) or row conversion raised; the underlying exception text is included, pointing at a database-level failure.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:615 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB connectivity and logs for the underlying error, then retry the list request."],"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"}