BerriAI/litellm · error · Exception
Policy {policy_id_a} not found
Error message
Policy {policy_id_a} not found What it means
Version-compare guard: find_unique for the first argument (policy_id_a) returned no row, so the version to compare from does not exist; raised before the second lookup or diff computation.
Source
Thrown at litellm/proxy/policy_engine/policy_registry.py:983
policy_id_b: str,
prisma_client: "PrismaClient",
) -> PolicyVersionCompareResponse:
"""
Compare two policy versions and return field-by-field diffs.
Args:
policy_id_a: First policy version ID
policy_id_b: Second policy version ID
prisma_client: The Prisma client instance
Returns:
PolicyVersionCompareResponse with both versions and field_diffs
"""
try:
a: Final = await _policy_table(prisma_client).find_unique(where={"policy_id": policy_id_a})
b: Final = await _policy_table(prisma_client).find_unique(where={"policy_id": policy_id_b})
if a is None:
raise Exception(f"Policy {policy_id_a} not found")
if b is None:
raise Exception(f"Policy {policy_id_b} not found")
resp_a: Final = _row_to_policy_db_response(a)
resp_b: Final = _row_to_policy_db_response(b)
# Compare fields that are part of policy content (not metadata)
compare_fields: Final = (
"inherit",
"description",
"guardrails_add",
"guardrails_remove",
"condition",
"pipeline",
)
field_diffs: Final[dict[str, dict[str, object]]] = {}
for field in compare_fields:
val_a = getattr(resp_a, field)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Verify the first policy/version ID exists via the versions list endpoint.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:983 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/15d4cb2e81bc01e0.
Report an issue: GitHub.