langgenius/dify · warning · ValueError
name is required when auto_generate is false
Error message
name is required when auto_generate is false
What it means
A Pydantic model_validator on ConversationRenamePayload: when auto_generate is false, the request must include a non-blank name. The schema also declares an anyOf contract in OpenAPI so clients can statically see the conditional requirement, but the server-side validator is the enforcement point. It is a 422-style validation error surfaced at request binding.
Source
Thrown at api/controllers/common/controller_schemas.py:65
"required": ["auto_generate"],
"type": "object",
},
{
"properties": {
"auto_generate": {**auto_generate_schema, "enum": [False]},
"name": non_blank_name_schema,
},
"required": ["name"],
"type": "object",
},
],
}
@model_validator(mode="after")
def validate_name_requirement(self):
if not self.auto_generate:
if self.name is None or not self.name.strip():
raise ValueError("name is required when auto_generate is false")
return self
# --- Message schemas ---
class MessageListQuery(BaseModel):
conversation_id: UUIDStrOrEmpty = Field(description="Conversation ID.")
first_id: UUIDStrOrEmpty | None = Field(
default=None,
description=(
"The ID of the first chat record on the current page. Omit this value to fetch the latest messages; "
"for subsequent pages, use the first message ID from the current list to fetch older messages."
),
)
limit: int = Field(
default=20,
ge=1,View on GitHub (pinned to ef8544b173)
Solutions
- Send a non-empty, trimmed name in the body: {"auto_generate": false, "name": "My conversation"}.
- If the user wants a generated title, send {"auto_generate": true} and omit name.
- Update the client to disable the submit action until name contains non-whitespace text.
- Re-read the generated OpenAPI anyOf schema for ConversationRenamePayload to keep the client contract in sync.
Example fix
// before
{ "auto_generate": false, "name": "" }
// after
{ "auto_generate": false, "name": "Weekly standup" } Defensive patterns
Strategy: validation
Validate before calling
def build_rename_payload(name: str | None, auto_generate: bool) -> dict:
if not auto_generate:
if name is None or not name.strip():
raise ValueError('A non-blank name is required when auto_generate is false')
return {'auto_generate': auto_generate, 'name': name if not auto_generate else None} Type guard
from typing import Any
def is_valid_rename_payload(payload: Any) -> bool:
auto = bool(payload.get('auto_generate', False))
name = payload.get('name')
return auto or (isinstance(name, str) and bool(name.strip())) Prevention
- Disable the rename submit button until name has non-whitespace text when auto-generate is off.
- Default the client to auto_generate=true when the user has not typed a name.
- Validate client-side against the OpenAPI anyOf schema before sending.
When it happens
Trigger: POSTing a conversation rename with {"auto_generate": false} and name omitted, null, or whitespace-only; or sending {"auto_generate": false, "name": " "}. Also triggered when clients default auto_generate to false (it is the field default) and forget to send a name.
Common situations: Client UI that exposes a rename textbox but submits before the user types; an API integration that always sends auto_generate=false and an empty name field; version drift after the validator was tightened to reject whitespace-only names.
Related errors
- KNOWLEDGE_FS_BASE_URL must be an absolute HTTP(S) URL
- NEW_USER_DEFAULT_MODELS entries must use 'model_type:provide
- NEW_USER_DEFAULT_MODELS contains duplicate model type: {mode
- Unsupported query list type.
- sort_by must be created_at or updated_at
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/7ba7ac8d8e13c299.
Report an issue: GitHub.