Dataset is_multimodal should default to False #20897

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

Originally created by @laipz8200 on GitHub (Dec 9, 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 branch (Dec 9, 2025 snapshot)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Create a new dataset through the console/API without providing the is_multimodal flag.
  2. Inspect the in-memory Dataset object before the first flush; is_multimodal remains unset/None.
  3. Downstream logic that branches on multimodal support sees an indeterminate value until a refresh, causing inconsistent behavior during creation workflows.

✔️ Expected Behavior

Dataset objects created without explicitly setting is_multimodal should default to False immediately so workflows that gate multimodal processing behave consistently.

Actual Behavior

New Dataset instances inherit no Python-level default, leaving is_multimodal as None until the row is reloaded from the database. This leads to inconsistent behavior when services check this flag during dataset creation.

Originally created by @laipz8200 on GitHub (Dec 9, 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 branch (Dec 9, 2025 snapshot) ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. Create a new dataset through the console/API without providing the `is_multimodal` flag. 2. Inspect the in-memory Dataset object before the first flush; `is_multimodal` remains unset/None. 3. Downstream logic that branches on multimodal support sees an indeterminate value until a refresh, causing inconsistent behavior during creation workflows. ### ✔️ Expected Behavior Dataset objects created without explicitly setting `is_multimodal` should default to `False` immediately so workflows that gate multimodal processing behave consistently. ### ❌ Actual Behavior New Dataset instances inherit no Python-level default, leaving `is_multimodal` as `None` until the row is reloaded from the database. This leads to inconsistent behavior when services check this flag during dataset creation.
yindo added the 💪 enhancement label 2026-02-21 20:09:42 -05:00
yindo closed this issue 2026-02-21 20:09:43 -05:00
Author
Owner

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

You're right—this is a confirmed bug. The Dataset model's is_multimodal attribute only has a database-level default of False, so new in-memory Dataset objects start with is_multimodal=None until they're flushed and reloaded, which can cause inconsistent behavior in downstream logic that expects a boolean value source.

To fix this, set a Python-level default for is_multimodal in the Dataset model. You can do this by adding default=False to the mapped_column definition:

is_multimodal = mapped_column(
    sa.Boolean,
    nullable=False,
    server_default=db.text("false"),
    default=False  # <-- add this line
)

This change will ensure that new Dataset instances always have is_multimodal=False in memory, matching the database default and stabilizing all boolean checks throughout the codebase. Based on the code review, this fix is safe and will not introduce regressions, since all consumers already expect a boolean value and treat False as the default for non-multimodal datasets source.

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 9, 2025): <!-- Answer --> You're right—this is a confirmed bug. The Dataset model's is_multimodal attribute only has a database-level default of False, so new in-memory Dataset objects start with is_multimodal=None until they're flushed and reloaded, which can cause inconsistent behavior in downstream logic that expects a boolean value [source](https://github.com/langgenius/dify/blob/d79d0a47a7a7da9a9de21768721cac58d6ad0a6f/api/models/dataset.py#L81-L81). To fix this, set a Python-level default for is_multimodal in the Dataset model. You can do this by adding default=False to the mapped_column definition: ```python is_multimodal = mapped_column( sa.Boolean, nullable=False, server_default=db.text("false"), default=False # <-- add this line ) ``` This change will ensure that new Dataset instances always have is_multimodal=False in memory, matching the database default and stabilizing all boolean checks throughout the codebase. Based on the code review, this fix is safe and will not introduce regressions, since all consumers already expect a boolean value and treat False as the default for non-multimodal datasets [source](https://github.com/langgenius/dify/blob/d79d0a47a7a7da9a9de21768721cac58d6ad0a6f/api/services/vector_service.py#L81-L332). <!-- 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/914a1cfd-7f5b-4fc1-951d-64e938e2646d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/914a1cfd-7f5b-4fc1-951d-64e938e2646d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/914a1cfd-7f5b-4fc1-951d-64e938e2646d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/914a1cfd-7f5b-4fc1-951d-64e938e2646d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/914a1cfd-7f5b-4fc1-951d-64e938e2646d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/914a1cfd-7f5b-4fc1-951d-64e938e2646d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/914a1cfd-7f5b-4fc1-951d-64e938e2646d?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%27re%20right%E2%80%94this%20is%20a%20confirmed%20bug.%20The%20Dataset%20model%27s%20is_multimodal%20attribute%20only%20has%20a%20database-level%20default%20of%20False%2C%20so%20new%20in-memory%20Dataset%20objects%20start%20with%20is_multimodal%3DNone%20until%20they%27re%20flushed%20and%20reloaded%2C%20which%20can%20cause%20inconsistent%20behavior%20in%20downstream%20logic%20that%20expects%20a%20boolean%20value%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/d79d0a47a7a7da9a9de21768721cac58d6ad0a6f/api/models/dataset.py%23L81-L81%29.%0A%0ATo%20fix%20this%2C%20set%20a%20Python-level%20default%20for%20is_multimodal%20in%20the%20Dataset%20model.%20You%20can%20do%20this%20by%20adding%20default%3DFalse%20to%20the%20mapped_column%20definition%3A%0A%0A%60%60%60python%0Ais_multimodal%20%3D%20mapped_column%28%0A%20%20%20%20sa.Boolean%2C%0A%20%20%20%20nullable%3DFalse%2C%0A%20%20%20%20server_default%3Ddb.text%28%22false%22%29%2C%0A%20%20%20%20default%3DFalse%20%20%23%20%3C--%20add%20this%20line%0A%29%0A%60%60%60%0A%0AThis%20change%20will%20ensure%20that%20new%20Dataset%20instances%20always%20have%20is_multimodal%3DFalse%20in%20memory%2C%20matching%20the%20database%20default%20and%20stabilizing%20all%20boolean%20checks%20throughout%20the%20codebase.%20Based%20on%20the%20code%20review%2C%20this%20fix%20is%20safe%20and%20will%20not%20introduce%20regressions%2C%20since%20all%20consumers%20already%20expect%20a%20boolean%20value%20and%20treat%20False%20as%20the%20default%20for%20non-multimodal%20datasets%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/d79d0a47a7a7da9a9de21768721cac58d6ad0a6f/api/services/vector_service.py%23L81-L332%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/29350)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20897