Conversation rename payload rejects auto-generate without name #20972

Closed
opened 2026-02-21 20:10:04 -05:00 by yindo · 1 comment
Owner

Originally created by @laipz8200 on GitHub (Dec 11, 2025).

Originally assigned to: @laipz8200 on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • "Please do not modify this template :) and fill in all the required fields."

Dify version

main (commit 1a877bb4d0)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Call either conversation rename endpoint with payload { "auto_generate": true } and omit name.
  2. The request is rejected with a validation error stating that name is required.
  3. If auto_generate is false, sending an empty or whitespace-only name passes validation and saves a blank conversation title.

✔️ Expected Behavior

  • When auto_generate is true, the rename endpoint should accept the request without a name so the system can generate it.
  • When auto_generate is false, the payload should require a non-empty name value.

Actual Behavior

  • Both console and service API rename endpoints currently reject auto-generate requests unless name is provided, so conversations cannot be auto-named.
  • Requests with auto_generate set to false allow empty names, resulting in blank conversation titles.
Originally created by @laipz8200 on GitHub (Dec 11, 2025). Originally assigned to: @laipz8200 on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] "Please do not modify this template :) and fill in all the required fields." ### Dify version main (commit 1a877bb4d0c6b921501862eef58583f341a322b9) ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. Call either conversation rename endpoint with payload `{ "auto_generate": true }` and omit `name`. 2. The request is rejected with a validation error stating that `name` is required. 3. If `auto_generate` is false, sending an empty or whitespace-only `name` passes validation and saves a blank conversation title. ### ✔️ Expected Behavior - When `auto_generate` is true, the rename endpoint should accept the request without a `name` so the system can generate it. - When `auto_generate` is false, the payload should require a non-empty `name` value. ### ❌ Actual Behavior - Both console and service API rename endpoints currently reject auto-generate requests unless `name` is provided, so conversations cannot be auto-named. - Requests with `auto_generate` set to false allow empty names, resulting in blank conversation titles.
yindo added the 🐞 bug label 2026-02-21 20:10:04 -05:00
yindo closed this issue 2026-02-21 20:10:04 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 11, 2025):

You’re correct—this is a validation bug in both the console and service API endpoints. The root cause is that the payload model for the service API (ConversationRenamePayload in api/controllers/service_api/app/conversation.py) always requires name, even when auto_generate is true, which blocks auto-naming requests without a name. Meanwhile, when auto_generate is false, there’s no check to ensure name is non-empty, so blank titles are saved. The web endpoint (api/controllers/web/conversation.py) passes both fields to the service layer without enforcing these rules either. The service method (ConversationService.rename in api/services/conversation_service.py) also doesn’t validate name for manual renames or allow omission for auto-generation, which explains the behavior you’re seeing.

To fix this, update the payload validation so that when auto_generate is true, name is not required, and when auto_generate is false, name must be present and non-empty (not just whitespace). In Pydantic, you can use a root_validator for this conditional logic. You may also want to add a manual check in the controller or service layer for extra safety.

Example (Pydantic root validator):

from pydantic import BaseModel, Field, root_validator

class ConversationRenamePayload(BaseModel):
    name: str = Field(default=None, description="New conversation name")
    auto_generate: bool = Field(default=False, description="Auto-generate conversation name")

    @root_validator
    def check_name_requirements(cls, values):
        auto_generate = values.get('auto_generate')
        name = values.get('name')
        if auto_generate:
            # name should be None or ignored
            return values
        if not name or not name.strip():
            raise ValueError("name is required and cannot be empty when auto_generate is false")
        return values

This will ensure the API behaves as expected: auto-generate mode works without a name, and manual mode requires a non-empty name.
You can reinforce this with a similar check in the controller or service method if you want to be extra defensive.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 11, 2025): <!-- Answer --> You’re correct—this is a validation bug in both the console and service API endpoints. The root cause is that the payload model for the service API (ConversationRenamePayload in api/controllers/service_api/app/conversation.py) always requires name, even when auto_generate is true, which blocks auto-naming requests without a name. Meanwhile, when auto_generate is false, there’s no check to ensure name is non-empty, so blank titles are saved. The web endpoint (api/controllers/web/conversation.py) passes both fields to the service layer without enforcing these rules either. The service method (ConversationService.rename in api/services/conversation_service.py) also doesn’t validate name for manual renames or allow omission for auto-generation, which explains the behavior you’re seeing. To fix this, update the payload validation so that when auto_generate is true, name is not required, and when auto_generate is false, name must be present and non-empty (not just whitespace). In Pydantic, you can use a root_validator for this conditional logic. You may also want to add a manual check in the controller or service layer for extra safety. Example (Pydantic root validator): ```python from pydantic import BaseModel, Field, root_validator class ConversationRenamePayload(BaseModel): name: str = Field(default=None, description="New conversation name") auto_generate: bool = Field(default=False, description="Auto-generate conversation name") @root_validator def check_name_requirements(cls, values): auto_generate = values.get('auto_generate') name = values.get('name') if auto_generate: # name should be None or ignored return values if not name or not name.strip(): raise ValueError("name is required and cannot be empty when auto_generate is false") return values ``` This will ensure the API behaves as expected: auto-generate mode works without a name, and manual mode requires a non-empty name. You can reinforce this with a similar check in the controller or service method if you want to be extra defensive. References: - [Web endpoint implementation](https://github.com/langgenius/dify/blob/1a877bb4d0c6b921501862eef58583f341a322b9/api/controllers/web/conversation.py#L133-L177) - [Service API endpoint and payload model](https://github.com/langgenius/dify/blob/1a877bb4d0c6b921501862eef58583f341a322b9/api/controllers/service_api/app/conversation.py#L39-L161) - [ConversationService.rename logic](https://github.com/langgenius/dify/blob/1a877bb4d0c6b921501862eef58583f341a322b9/api/services/conversation_service.py#L116-L157) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1bf728e2-9d6f-4c58-ad1f-3a107d5cefbf?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=You%E2%80%99re%20correct%E2%80%94this%20is%20a%20validation%20bug%20in%20both%20the%20console%20and%20service%20API%20endpoints.%20The%20root%20cause%20is%20that%20the%20payload%20model%20for%20the%20service%20API%20%28ConversationRenamePayload%20in%20api/controllers/service_api/app/conversation.py%29%20always%20requires%20name%2C%20even%20when%20auto_generate%20is%20true%2C%20which%20blocks%20auto-naming%20requests%20without%20a%20name.%20Meanwhile%2C%20when%20auto_generate%20is%20false%2C%20there%E2%80%99s%20no%20check%20to%20ensure%20name%20is%20non-empty%2C%20so%20blank%20titles%20are%20saved.%20The%20web%20endpoint%20%28api/controllers/web/conversation.py%29%20passes%20both%20fields%20to%20the%20service%20layer%20without%20enforcing%20these%20rules%20either.%20The%20service%20method%20%28ConversationService.rename%20in%20api/services/conversation_service.py%29%20also%20doesn%E2%80%99t%20validate%20name%20for%20manual%20renames%20or%20allow%20omission%20for%20auto-generation%2C%20which%20explains%20the%20behavior%20you%E2%80%99re%20seeing.%20%20%0A%20%0ATo%20fix%20this%2C%20update%20the%20payload%20validation%20so%20that%20when%20auto_generate%20is%20true%2C%20name%20is%20not%20required%2C%20and%20when%20auto_generate%20is%20false%2C%20name%20must%20be%20present%20and%20non-empty%20%28not%20just%20whitespace%29.%20In%20Pydantic%2C%20you%20can%20use%20a%20root_validator%20for%20this%20conditional%20logic.%20You%20may%20also%20want%20to%20add%20a%20manual%20check%20in%20the%20controller%20or%20service%20layer%20for%20extra%20safety.%0A%0AExample%20%28Pydantic%20root%20validator%29%3A%0A%0A%60%60%60python%0Afrom%20pydantic%20import%20BaseModel%2C%20Field%2C%20root_validator%0A%0Aclass%20ConversationRenamePayload%28BaseModel%29%3A%0A%20%20%20%20name%3A%20str%20%3D%20Field%28default%3DNone%2C%20description%3D%22New%20conversation%20name%22%29%0A%20%20%20%20auto_generate%3A%20bool%20%3D%20Field%28default%3DFalse%2C%20description%3D%22Auto-generate%20conversation%20name%22%29%0A%0A%20%20%20%20%40root_validator%0A%20%20%20%20def%20check_name_requirements%28cls%2C%20values%29%3A%0A%20%20%20%20%20%20%20%20auto_generate%20%3D%20values.get%28%27auto_generate%27%29%0A%20%20%20%20%20%20%20%20name%20%3D%20values.get%28%27name%27%29%0A%20%20%20%20%20%20%20%20if%20auto_generate%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20name%20should%20be%20None%20or%20ignored%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20values%0A%20%20%20%20%20%20%20%20if%20not%20name%20or%20not%20name.strip%28%29%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError%28%22name%20is%20required%20and%20cannot%20be%20empty%20when%20auto_generate%20is%20false%22%29%0A%20%20%20%20%20%20%20%20return%20values%0A%60%60%60%0A%0AThis%20will%20ensure%20the%20API%20behaves%20as%20expected%3A%20auto-generate%20mode%20works%20without%20a%20name%2C%20and%20manual%20mode%20requires%20a%20non-empty%20name.%20%20%0AYou%20can%20reinforce%20this%20with%20a%20similar%20check%20in%20the%20controller%20or%20service%20method%20if%20you%20want%20to%20be%20extra%20defensive.%0A%0AReferences%3A%20%20%0A-%20%5BWeb%20endpoint%20implementation%5D%28https%3A//github.com/langgenius/dify/blob/1a877bb4d0c6b921501862eef58583f341a322b9/api/controllers/web/conversation.py%23L133-L177%29%20%20%0A-%20%5BService%20API%20endpoint%20and%20payload%20model%5D%28https%3A//github.com/langgenius/dify/blob/1a877bb4d0c6b921501862eef58583f341a322b9/api/controllers/service_api/app/conversation.py%23L39-L161%29%20%20%0A-%20%5BConversationService.rename%20logic%5D%28https%3A//github.com/langgenius/dify/blob/1a877bb4d0c6b921501862eef58583f341a322b9/api/services/conversation_service.py%23L116-L157%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/29509)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20972