BerriAI/litellm · error · Exception

Source policy {source_policy_id} not found

Error message

Source policy {source_policy_id} not found

What it means

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.

Source

Thrown at litellm/proxy/policy_engine/policy_registry.py:797

        Create a new draft version of a policy. Copies all fields from the source.
        Source is current production if source_policy_id is None.

        Args:
            policy_name: Name of the policy
            prisma_client: The Prisma client instance
            source_policy_id: Policy ID to clone from; if None, use current production
            created_by: User who created the version

        Returns:
            PolicyDBResponse for the new draft version
        """
        try:
            if source_policy_id is not None:
                source = await _policy_version_source_table(prisma_client).find_unique(
                    where={"policy_id": source_policy_id}
                )
                if source is None:
                    raise Exception(f"Source policy {source_policy_id} not found")
                if source.policy_name != policy_name:
                    raise Exception(f"Source policy name '{source.policy_name}' does not match '{policy_name}'")
            else:
                # Find current production version for this policy_name
                prod: Final = await _policy_version_source_table(prisma_client).find_first(
                    where={
                        "policy_name": policy_name,
                        "version_status": "production",
                    }
                )
                if prod is None:
                    raise Exception(f"No production version found for policy '{policy_name}'")
                source = prod

            # Next version number
            latest: Final = await _policy_version_source_table(prisma_client).find_first(
                where={"policy_name": policy_name},
                order={"version_number": "desc"},

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide the ID of an existing source policy version to fork from; list versions to find it.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:797 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5d3b6d80e64f9253. Report an issue: GitHub.