{"record":{"id":"22e55f9f146ae3bc","repo":"BerriAI/litellm","slug":"no-production-version-found-for-policy-policy-na","errorCode":null,"errorMessage":"No production version found for policy '{policy_name}'","messagePattern":"No production version found for policy '(.+?)'","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":809,"sourceCode":"        try:\n            if source_policy_id is not None:\n                source = await _policy_version_source_table(prisma_client).find_unique(\n                    where={\"policy_id\": source_policy_id}\n                )\n                if source is None:\n                    raise Exception(f\"Source policy {source_policy_id} not found\")\n                if source.policy_name != policy_name:\n                    raise Exception(f\"Source policy name '{source.policy_name}' does not match '{policy_name}'\")\n            else:\n                # Find current production version for this policy_name\n                prod: Final = await _policy_version_source_table(prisma_client).find_first(\n                    where={\n                        \"policy_name\": policy_name,\n                        \"version_status\": \"production\",\n                    }\n                )\n                if prod is None:\n                    raise Exception(f\"No production version found for policy '{policy_name}'\")\n                source = prod\n\n            # Next version number\n            latest: Final = await _policy_version_source_table(prisma_client).find_first(\n                where={\"policy_name\": policy_name},\n                order={\"version_number\": \"desc\"},\n            )\n            next_num: Final = (latest.version_number + 1) if latest else 1\n\n            now: Final = datetime.now(timezone.utc)\n            # Set is_latest=False on all existing versions for this policy_name\n            await _policy_table(prisma_client).update_many(\n                where={\"policy_name\": policy_name},\n                data={\"is_latest\": False},\n            )\n\n            data: Final[dict[str, object]] = {\n                \"policy_name\": policy_name,","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L791-L827","documentation":"Version-creation guard in the policy registry: no source_policy_id was given, so the current production version of the named policy was to be cloned, but no production version exists for that policy_name.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:809 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Publish a version and promote it to production before referencing the policy's production version."],"exampleFix":null,"handlingStrategy":"type-guard","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"}