{"record":{"id":"7ba7ac8d8e13c299","repo":"langgenius/dify","slug":"name-is-required-when-auto-generate-is-false","errorCode":null,"errorMessage":"name is required when auto_generate is false","messagePattern":"name is required when auto_generate is false","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"api/controllers/common/controller_schemas.py","lineNumber":65,"sourceCode":"                    \"required\": [\"auto_generate\"],\n                    \"type\": \"object\",\n                },\n                {\n                    \"properties\": {\n                        \"auto_generate\": {**auto_generate_schema, \"enum\": [False]},\n                        \"name\": non_blank_name_schema,\n                    },\n                    \"required\": [\"name\"],\n                    \"type\": \"object\",\n                },\n            ],\n        }\n\n    @model_validator(mode=\"after\")\n    def validate_name_requirement(self):\n        if not self.auto_generate:\n            if self.name is None or not self.name.strip():\n                raise ValueError(\"name is required when auto_generate is false\")\n        return self\n\n\n# --- Message schemas ---\n\n\nclass MessageListQuery(BaseModel):\n    conversation_id: UUIDStrOrEmpty = Field(description=\"Conversation ID.\")\n    first_id: UUIDStrOrEmpty | None = Field(\n        default=None,\n        description=(\n            \"The ID of the first chat record on the current page. Omit this value to fetch the latest messages; \"\n            \"for subsequent pages, use the first message ID from the current list to fetch older messages.\"\n        ),\n    )\n    limit: int = Field(\n        default=20,\n        ge=1,","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/common/controller_schemas.py#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{ \"auto_generate\": false, \"name\": \"\" }\n// after\n{ \"auto_generate\": false, \"name\": \"Weekly standup\" }","handlingStrategy":"validation","validationCode":"def build_rename_payload(name: str | None, auto_generate: bool) -> dict:\n    if not auto_generate:\n        if name is None or not name.strip():\n            raise ValueError('A non-blank name is required when auto_generate is false')\n    return {'auto_generate': auto_generate, 'name': name if not auto_generate else None}","typeGuard":"from typing import Any\n\ndef is_valid_rename_payload(payload: Any) -> bool:\n    auto = bool(payload.get('auto_generate', False))\n    name = payload.get('name')\n    return auto or (isinstance(name, str) and bool(name.strip()))","tryCatchPattern":null,"preventionTips":["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."],"tags":["pydantic","validation","conversation","request-schema"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}