BerriAI/litellm · error · ValueError
fallback_models must not contain duplicates
Error message
fallback_models must not contain duplicates
What it means
Pydantic field validator on fallback_models in the fallback create/update request: the list of fallback model names contains duplicates. Since fallbacks are tried in priority order, duplicates are ambiguous and rejected; deduplicate the list.
Source
Thrown at litellm/types/management_endpoints/router_settings_endpoints.py:31
"""Request model for creating/updating fallbacks"""
model: str = Field(description="The model name to configure fallbacks for (e.g., 'gpt-3.5-turbo')")
fallback_models: list[str] = Field(
description="List of fallback model names in order of priority",
min_length=1,
)
fallback_type: Literal["general", "context_window", "content_policy"] = Field(
default="general",
description="Type of fallback: 'general' (default), 'context_window', or 'content_policy'",
)
@field_validator("fallback_models")
@classmethod
def validate_fallback_models(cls, v: list[str]) -> list[str]:
if not v:
raise ValueError("fallback_models must contain at least one model")
if len(v) != len(set(v)):
raise ValueError("fallback_models must not contain duplicates")
return v
@field_validator("model")
@classmethod
def validate_model(cls, v: str) -> str:
if not v or not v.strip():
raise ValueError("model must be a non-empty string")
return v.strip()
class FallbackResponse(BaseModel):
"""Response model for fallback operations"""
model: str = Field(description="The model name")
fallback_models: list[str] = Field(description="List of fallback model names")
fallback_type: str = Field(description="Type of fallback")
message: str = Field(description="Success message")
View on GitHub (pinned to 77b7c6c40c)
Solutions
- De-duplicate fallback_models, keeping each model only once.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/types/management_endpoints/router_settings_endpoints.py:31 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/f891420d87e9dafb.
Report an issue: GitHub.