langgenius/dify · error · ValueError
NEW_USER_DEFAULT_MODELS contains duplicate model type: {mode
Error message
NEW_USER_DEFAULT_MODELS contains duplicate model type: {model_type} What it means
Raised by NEW_USER_DEFAULT_MODEL_LIST when two entries share the same model_type (first segment). The default-models logic reserves one default per model type, so duplicates would non-deterministically override each other at app-provisioning time.
Source
Thrown at api/configs/feature/__init__.py:335
default="",
)
@property
def NEW_USER_DEFAULT_MODEL_LIST(self) -> list[tuple[str, str, str]]:
default_models: list[tuple[str, str, str]] = []
configured_model_types: set[str] = set()
for item in self.NEW_USER_DEFAULT_MODELS.split(","):
if not item.strip():
continue
parts = tuple(part.strip() for part in item.split(":", 2))
if len(parts) != 3 or not all(parts):
raise ValueError("NEW_USER_DEFAULT_MODELS entries must use 'model_type:provider:model' format")
model_type, provider, model = parts
if model_type in configured_model_types:
raise ValueError(f"NEW_USER_DEFAULT_MODELS contains duplicate model type: {model_type}")
configured_model_types.add(model_type)
default_models.append((model_type, provider, model))
return default_models
class MarketplaceConfig(BaseSettings):
"""
Configuration for marketplace
"""
MARKETPLACE_ENABLED: bool = Field(
description="Enable or disable marketplace",
default=True,
)
MARKETPLACE_API_URL: HttpUrl = Field(View on GitHub (pinned to ef8544b173)
Solutions
- Keep at most one entry per model_type (e.g. only one 'llm' entry).
- If you need multiple LLMs, set them per-workspace after provisioning rather than in NEW_USER_DEFAULT_MODELS.
- Switch the second entry to a different model_type if a second default category is intended.
Example fix
// before NEW_USER_DEFAULT_MODELS=llm:openai:gpt-4o,llm:anthropic:claude-3 // after NEW_USER_DEFAULT_MODELS=llm:openai:gpt-4o
Defensive patterns
Strategy: validation
Validate before calling
def no_duplicate_model_type(entries: str) -> bool:
types = [e.split(':', 1)[0].strip() for e in entries.split(',') if e.strip()]
return len(types) == len(set(types)) Prevention
- Allow only one entry per model_type.
- Set additional models per-workspace after provisioning.
- Lint NEW_USER_DEFAULT_MODELS for duplicate first segments in CI.
When it happens
Trigger: Setting NEW_USER_DEFAULT_MODELS='llm:openai:gpt-4o,llm:anthropic:claude-3' — both entries have model_type 'llm'.
Common situations: Wanting to default multiple providers for the same type; misunderstanding that the keying is by model_type, not by provider.
Related errors
- NEW_USER_DEFAULT_MODELS entries must use 'model_type:provide
- KNOWLEDGE_FS_BASE_URL must be an absolute HTTP(S) URL
- KNOWLEDGE_FS_BASE_URL must include a valid port
- KNOWLEDGE_FS_BASE_URL must not include credentials, query, o
- KNOWLEDGE_FS_BASE_URL and KNOWLEDGE_FS_JWT_SECRET must be co
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/4cbf5ef046dfd3dc.
Report an issue: GitHub.