{"record":{"id":"d7d9097938527672","repo":"BerriAI/litellm","slug":"source-policy-name-source-policy-name-does-not","errorCode":null,"errorMessage":"Source policy name '{source.policy_name}' does not match '{policy_name}'","messagePattern":"Source policy name '(.+?)' does not match '(.+?)'","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":799,"sourceCode":"\n        Args:\n            policy_name: Name of the policy\n            prisma_client: The Prisma client instance\n            source_policy_id: Policy ID to clone from; if None, use current production\n            created_by: User who created the version\n\n        Returns:\n            PolicyDBResponse for the new draft version\n        \"\"\"\n        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","sourceCodeStart":781,"sourceCodeEnd":817,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L781-L817","documentation":"Version-creation guard in the policy registry: the source policy exists but its policy_name differs from the requested policy_name, preventing a draft being created under one policy from another policy's data.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:799 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a source_policy_id that belongs to the named policy; version operations cannot cross policy names."],"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"}