{"record":{"id":"b038038422040b87","repo":"BerriAI/litellm","slug":"invalid-status-new-status-use-published-or","errorCode":null,"errorMessage":"Invalid status '{new_status}'. Use 'published' or 'production'.","messagePattern":"Invalid status '(.+?)'\\. Use 'published' or 'production'\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":883,"sourceCode":"        Update a policy version's status. Valid transitions:\n        - draft -> published (sets published_at)\n        - published -> production (sets production_at, demotes current production to published, updates in-memory)\n        - production -> published (demotes, removes from in-memory)\n        - draft -> production: NOT allowed (must publish first)\n        - published -> draft: NOT allowed\n\n        Args:\n            policy_id: The policy version ID\n            new_status: \"published\" or \"production\"\n            prisma_client: The Prisma client instance\n            updated_by: User who updated\n\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,","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L865-L901","documentation":"Status-transition validator in the policy version workflow: new_status is not one of the two allowed values ('published' or 'production'); the supplied value is echoed back. This guards the state machine before any DB write happens.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:883 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use 'published' or 'production' as the new status value."],"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"}