{"record":{"id":"ee463ae698bd94be","repo":"BerriAI/litellm","slug":"only-draft-versions-can-be-updated-publish-or-cre","errorCode":null,"errorMessage":"Only draft versions can be updated. Publish or create a new version to change published/production.","messagePattern":"Only draft versions can be updated\\. Publish or create a new version to change published/production\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_endpoints.py","lineNumber":456,"sourceCode":"            \"guardrails_add\": [\"pii_masking\", \"toxicity_filter\"]\n        }'\n    ```\n    \"\"\"\n    from litellm.proxy.proxy_server import prisma_client\n\n    if prisma_client is None:\n        raise HTTPException(status_code=500, detail=\"Database not connected\")\n\n    try:\n        # Check if policy exists and is draft (only drafts can be updated)\n        existing: Final = await get_policy_registry().get_policy_by_id_from_db(\n            policy_id=policy_id,\n            prisma_client=prisma_client,\n        )\n        if existing is None:\n            raise HTTPException(status_code=404, detail=f\"Policy with ID {policy_id} not found\")\n        if getattr(existing, \"version_status\", \"production\") != \"draft\":\n            raise HTTPException(\n                status_code=400,\n                detail=\"Only draft versions can be updated. Publish or create a new version to change published/production.\",\n            )\n\n        updated_by: Final = user_api_key_dict.user_id\n        result: Final = await get_policy_registry().update_policy_in_db(\n            policy_id=policy_id,\n            policy_request=request,\n            prisma_client=prisma_client,\n            updated_by=updated_by,\n        )\n        return result\n    except HTTPException:\n        raise\n    except Exception as e:\n        verbose_proxy_logger.exception(\"Error updating policy: %s\", e)\n        raise HTTPException(status_code=500, detail=str(e))\n","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_endpoints.py#L438-L474","documentation":"Raised in the policy update endpoint when the existing version's version_status is not 'draft': only draft versions are mutable, so published/production versions must be cloned into a new draft to change.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_endpoints.py:456 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create a new draft version of the policy and apply changes there; published/production versions are immutable.","Promote the new draft through publish → production to roll out the change."],"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"}