{"record":{"id":"ec67ce8985a24f64","repo":"BerriAI/litellm","slug":"only-draft-versions-can-be-published-current-stat","errorCode":null,"errorMessage":"Only draft versions can be published. Current status: '{current}'.","messagePattern":"Only draft versions can be published\\. Current status: '(.+?)'\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":895,"sourceCode":"\n        Returns:\n            PolicyDBResponse for the updated version\n        \"\"\"\n        try:\n            if new_status not in (\"published\", \"production\"):\n                raise Exception(f\"Invalid status '{new_status}'. Use 'published' or 'production'.\")\n\n            row: Final = await _policy_table(prisma_client).find_unique(where={\"policy_id\": policy_id})\n            if row is None:\n                raise Exception(f\"Policy with ID {policy_id} not found\")\n\n            current: Final = getattr(row, \"version_status\", \"production\")\n            policy_name: Final = row.policy_name\n            now: Final = datetime.now(timezone.utc)\n\n            if new_status == \"published\":\n                if current != \"draft\":\n                    raise Exception(f\"Only draft versions can be published. Current status: '{current}'.\")\n                updated = await _policy_table(prisma_client).update(\n                    where={\"policy_id\": policy_id},\n                    data={\n                        \"version_status\": \"published\",\n                        \"published_at\": now,\n                        \"updated_at\": now,\n                        \"updated_by\": updated_by,\n                    },\n                )\n                return _row_to_policy_db_response(updated)\n\n            # new_status == \"production\"\n            if current not in (\"draft\", \"published\"):\n                raise Exception(\n                    f\"Only draft or published versions can be promoted to production. Current: '{current}'.\"\n                )\n            # Plan: \"draft -> production\" NOT allowed\n            if current == \"draft\":","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L877-L913","documentation":"Status-transition guard in the policy registry: publishing (setting published_at) is only allowed from the draft status, but the row's current version_status is something else (already published or production).","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:895 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only draft versions can be published; create a new draft from the current version and publish that."],"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-14T05:17:10.506Z"}