{"record":{"id":"5d3b6d80e64f9253","repo":"BerriAI/litellm","slug":"source-policy-source-policy-id-not-found","errorCode":null,"errorMessage":"Source policy {source_policy_id} not found","messagePattern":"Source policy (.+?) not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":797,"sourceCode":"        Create a new draft version of a policy. Copies all fields from the source.\n        Source is current production if source_policy_id is None.\n\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\"},","sourceCodeStart":779,"sourceCodeEnd":815,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L779-L815","documentation":"New-draft-version guard: when source_policy_id is supplied, the lookup of that source policy version returned no row — the ID to clone from does not exist, so the draft cannot be created from it.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:797 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide the ID of an existing source policy version to fork from; list versions to find it."],"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-14T05:17:10.506Z"}