BerriAI/litellm · error · HTTPException
Policy with name '{request.policy_name}' already exists
Error message
Policy with name '{request.policy_name}' already exists What it means
Uniqueness guard when creating a policy: the underlying add_policy_to_db failed with a 'unique constraint' error, i.e. a policy with the same policy_name already exists, so the request is rejected as a 400.
Source
Thrown at litellm/proxy/policy_engine/policy_endpoints.py:208
```
"""
from litellm.proxy.proxy_server import prisma_client
if prisma_client is None:
raise HTTPException(status_code=500, detail="Database not connected")
try:
created_by: Final = user_api_key_dict.user_id
result: Final = await get_policy_registry().add_policy_to_db(
policy_request=request,
prisma_client=prisma_client,
created_by=created_by,
)
return result
except Exception as e:
verbose_proxy_logger.exception("Error creating policy: %s", e)
if "unique constraint" in str(e).lower():
raise HTTPException(
status_code=400,
detail=f"Policy with name '{request.policy_name}' already exists",
)
raise HTTPException(status_code=500, detail=str(e))
# ─────────────────────────────────────────────────────────────────────────────
# Policy Versioning Endpoints (must be before /policies/{policy_id} to avoid path conflicts)
# ─────────────────────────────────────────────────────────────────────────────
@router.get(
"/policies/name/{policy_name}/versions",
tags=["Policies"],
dependencies=[Depends(user_api_key_auth)],
response_model=PolicyVersionListResponse,
)
async def list_policy_versions(policy_name: str):View on GitHub (pinned to 77b7c6c40c)
Solutions
- Choose a different policy_name, or update the existing policy instead of creating a new one.
- Delete the existing policy first if a fresh create is intended.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/policy_engine/policy_endpoints.py:208 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/66becc9812b77326.
Report an issue: GitHub.