BerriAI/litellm · error · Exception

Source policy name '{source.policy_name}' does not match '{p

Error message

Source policy name '{source.policy_name}' does not match '{policy_name}'

What it means

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.

Source

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

        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"},
            )
            next_num: Final = (latest.version_number + 1) if latest else 1

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass a source_policy_id that belongs to the named policy; version operations cannot cross policy names.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:799 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/d7d9097938527672. Report an issue: GitHub.