{"record":{"id":"107134110ecd5913","repo":"BerriAI/litellm","slug":"cannot-promote-draft-directly-to-production-publi","errorCode":null,"errorMessage":"Cannot promote draft directly to production. Publish the version first.","messagePattern":"Cannot promote draft directly to production\\. Publish the version first\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":914,"sourceCode":"                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\":\n                raise Exception(\"Cannot promote draft directly to production. Publish the version first.\")\n\n            # Demote current production to published\n            await _policy_table(prisma_client).update_many(\n                where={\n                    \"policy_name\": policy_name,\n                    \"version_status\": \"production\",\n                },\n                data={\n                    \"version_status\": \"published\",\n                    \"updated_at\": now,\n                    \"updated_by\": updated_by,\n                },\n            )\n\n            # Promote this version to production\n            updated = await _policy_table(prisma_client).update(\n                where={\"policy_id\": policy_id},\n                data={","sourceCodeStart":896,"sourceCodeEnd":932,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L896-L932","documentation":"Policy version state-machine guard: an attempt was made to move a draft version directly to 'production'. The allowed path is draft -> published -> production, so the caller must publish the version first; raised before any status update is written.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:914 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Publish the draft version first, then promote it to production."],"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"}