BerriAI/litellm · error · HTTPException
" | ".join(e.message for e in scope_errors)
Error message
" | ".join(e.message for e in scope_errors)
What it means
Raised when PolicyValidator.find_invalid_scopes found concrete team/key/model entries in the attachment request that do not exist in the DB or router; the per-scope error messages are joined and returned.
Source
Thrown at litellm/proxy/policy_engine/policy_endpoints.py:784
policy_names: Final = {p.policy_name for p in policies}
if request.policy_name not in policy_names:
raise HTTPException(
status_code=404,
detail=f"Policy '{request.policy_name}' not found. Create the policy first.",
)
# Reject concrete team/key/model scope entries that don't resolve to a real
# entity. Wildcard patterns are allowed through (they may match zero today).
scope_errors: Final = await PolicyValidator(
prisma_client=prisma_client, llm_router=llm_router
).find_invalid_scope_entries(
policy_name=request.policy_name,
teams=request.teams,
keys=request.keys,
models=request.models,
)
if scope_errors:
raise HTTPException(status_code=400, detail=" | ".join(e.message for e in scope_errors))
created_by: Final = user_api_key_dict.user_id
result: Final = await get_attachment_registry().add_attachment_to_db(
attachment_request=request,
prisma_client=prisma_client,
created_by=created_by,
)
return result
except HTTPException:
raise
except Exception as e:
verbose_proxy_logger.exception("Error creating policy attachment: %s", e)
raise HTTPException(status_code=500, detail=str(e))
@router.get(
"/policies/attachments/{attachment_id}",
tags=["Policies"],View on GitHub (pinned to 77b7c6c40c)
Solutions
- Fix the listed scope errors: ensure referenced teams, keys, and models exist and are valid for the policy scope.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/policy_engine/policy_endpoints.py:784 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/4dbec41e7e898216.
Report an issue: GitHub.