{"record":{"id":"d73b1ccad1de0b84","repo":"BerriAI/litellm","slug":"only-draft-versions-can-be-updated-this-policy-ha","errorCode":null,"errorMessage":"Only draft versions can be updated. This policy has status '{version_status}'.","messagePattern":"Only draft versions can be updated\\. This policy has status '(.+?)'\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":458,"sourceCode":"        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\n            if policy_request.guardrails_remove is not None:\n                update_data[\"guardrails_remove\"] = policy_request.guardrails_remove\n            if policy_request.condition is not None:","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L440-L476","documentation":"Versioning guard in the policy registry: only draft versions are editable, but the policy being updated has the shown version_status (e.g. 'published' or 'production'). Edits must go through a new draft created from the version.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:458 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create a new draft version to make changes; only draft versions are editable."],"exampleFix":null,"handlingStrategy":"validation","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"}