BerriAI/litellm · error · Exception

Policy with ID {policy_id} not found

Error message

Policy with ID {policy_id} not found

What it means

Update-policy guard: find_unique on the policy table for the given policy_id returned no row, so the version being updated no longer exists (deleted concurrently or never existed); raised before any update data is applied.

Source

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

        """
        Update a policy in the database. Only draft versions can be updated.

        Args:
            policy_id: The ID of the policy to update
            policy_request: The policy update request
            prisma_client: The Prisma client instance
            updated_by: User who updated the policy

        Returns:
            PolicyDBResponse with the updated policy

        Raises:
            Exception: If policy is not in draft status (only drafts are editable).
        """
        try:
            existing: Final = await _policy_table(prisma_client).find_unique(where={"policy_id": policy_id})
            if existing is None:
                raise Exception(f"Policy with ID {policy_id} not found")
            version_status: Final = getattr(existing, "version_status", "production")
            if version_status != "draft":
                raise Exception(f"Only draft versions can be updated. This policy has status '{version_status}'.")

            # Build update data - only include fields that are set
            update_data: Final[dict[str, object]] = {
                "updated_at": datetime.now(timezone.utc),
                "updated_by": updated_by,
            }

            if policy_request.policy_name is not None:
                update_data["policy_name"] = policy_request.policy_name
            if policy_request.inherit is not None:
                update_data["inherit"] = policy_request.inherit
            if policy_request.description is not None:
                update_data["description"] = policy_request.description
            if policy_request.guardrails_add is not None:
                update_data["guardrails_add"] = policy_request.guardrails_add

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Confirm the policy_id via the list endpoint; the policy may have been deleted.
Defensive patterns

Strategy: type-guard

When it happens

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