{"record":{"id":"07561dbb1c64405b","repo":"BerriAI/litellm","slug":"policy-with-id-policy-id-not-found-07561d","errorCode":null,"errorMessage":"Policy with ID {policy_id} not found","messagePattern":"Policy with ID (.+?) not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":455,"sourceCode":"        \"\"\"\n        Update a policy in the database. Only draft versions can be updated.\n\n        Args:\n            policy_id: The ID of the policy to update\n            policy_request: The policy update request\n            prisma_client: The Prisma client instance\n            updated_by: User who updated the policy\n\n        Returns:\n            PolicyDBResponse with the updated policy\n\n        Raises:\n            Exception: If policy is not in draft status (only drafts are editable).\n        \"\"\"\n        try:\n            existing: Final = await _policy_table(prisma_client).find_unique(where={\"policy_id\": policy_id})\n            if existing is None:\n                raise Exception(f\"Policy with ID {policy_id} not found\")\n            version_status: Final = getattr(existing, \"version_status\", \"production\")\n            if version_status != \"draft\":\n                raise Exception(f\"Only draft versions can be updated. This policy has status '{version_status}'.\")\n\n            # Build update data - only include fields that are set\n            update_data: Final[dict[str, object]] = {\n                \"updated_at\": datetime.now(timezone.utc),\n                \"updated_by\": updated_by,\n            }\n\n            if policy_request.policy_name is not None:\n                update_data[\"policy_name\"] = policy_request.policy_name\n            if policy_request.inherit is not None:\n                update_data[\"inherit\"] = policy_request.inherit\n            if policy_request.description is not None:\n                update_data[\"description\"] = policy_request.description\n            if policy_request.guardrails_add is not None:\n                update_data[\"guardrails_add\"] = policy_request.guardrails_add","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L437-L473","documentation":"Update-policy guard: find_unique on the policy table for the given policy_id returned no row, so the version being updated no longer exists (deleted concurrently or never existed); raised before any update data is applied.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:455 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the policy_id via the list endpoint; the policy may have been deleted."],"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"}