{"record":{"id":"15d4cb2e81bc01e0","repo":"BerriAI/litellm","slug":"policy-policy-id-a-not-found","errorCode":null,"errorMessage":"Policy {policy_id_a} not found","messagePattern":"Policy (.+?) not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":983,"sourceCode":"        policy_id_b: str,\n        prisma_client: \"PrismaClient\",\n    ) -> PolicyVersionCompareResponse:\n        \"\"\"\n        Compare two policy versions and return field-by-field diffs.\n\n        Args:\n            policy_id_a: First policy version ID\n            policy_id_b: Second policy version ID\n            prisma_client: The Prisma client instance\n\n        Returns:\n            PolicyVersionCompareResponse with both versions and field_diffs\n        \"\"\"\n        try:\n            a: Final = await _policy_table(prisma_client).find_unique(where={\"policy_id\": policy_id_a})\n            b: Final = await _policy_table(prisma_client).find_unique(where={\"policy_id\": policy_id_b})\n            if a is None:\n                raise Exception(f\"Policy {policy_id_a} not found\")\n            if b is None:\n                raise Exception(f\"Policy {policy_id_b} not found\")\n\n            resp_a: Final = _row_to_policy_db_response(a)\n            resp_b: Final = _row_to_policy_db_response(b)\n\n            # Compare fields that are part of policy content (not metadata)\n            compare_fields: Final = (\n                \"inherit\",\n                \"description\",\n                \"guardrails_add\",\n                \"guardrails_remove\",\n                \"condition\",\n                \"pipeline\",\n            )\n            field_diffs: Final[dict[str, dict[str, object]]] = {}\n            for field in compare_fields:\n                val_a = getattr(resp_a, field)","sourceCodeStart":965,"sourceCodeEnd":1001,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L965-L1001","documentation":"Version-compare guard: find_unique for the first argument (policy_id_a) returned no row, so the version to compare from does not exist; raised before the second lookup or diff computation.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:983 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the first policy/version ID exists via the versions list endpoint."],"exampleFix":null,"handlingStrategy":"type-guard","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"}