{"record":{"id":"21ec7b082bbc408e","repo":"BerriAI/litellm","slug":"error-getting-policy-from-db-e","errorCode":null,"errorMessage":"Error getting policy from DB: {e}","messagePattern":"Error getting policy from DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":568,"sourceCode":"        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})\n\n            if policy is None:\n                return None\n\n            return _row_to_policy_db_response(policy)\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error getting policy from DB: %s\", e)\n            raise Exception(f\"Error getting policy from DB: {e}\")\n\n    def get_policy_by_id_for_request(self, policy_id: str) -> tuple[str, Policy] | None:\n        \"\"\"\n        Return a policy version by ID from in-memory cache (no DB access).\n\n        Used when the request body specifies policy_<uuid> to execute a specific version\n        (e.g. published or draft). The cache is populated by sync_policies_from_db,\n        which loads draft and published versions keyed by policy_id.\n\n        Args:\n            policy_id: The policy version ID (raw UUID, no prefix)\n\n        Returns:\n            (policy_name, Policy) if found, None otherwise\n        \"\"\"\n        return self._policies_by_id.get(policy_id)\n\n    async def get_all_policies_from_db(","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L550-L586","documentation":"Catch-all from get_policy_by_id_from_db: the find_unique query or the row-to-response conversion failed with a database/deserialization error; the original exception is embedded. A missing policy returns None instead — this error means the lookup itself broke.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:568 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB connectivity and logs; verify the policy ID, 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-14T00:17:10.932Z"}