File List upload bug #12949

Closed
opened 2026-02-21 19:09:49 -05:00 by yindo · 2 comments
Owner

Originally created by @CJack812 on GitHub (Apr 15, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.2

Cloud or Self Hosted

Cloud

Steps to reproduce

When adding a field that contains a file list to the workflow, and this field is optional.
During debugging in the studio interface, if no files are uploaded, it correctly follows the logic where the file list is empty.
However, after publishing and running, if no files are uploaded, an error occurs.

Figure 1: Works correctly during debugging
Image
Figure 2: Error occurs during execution
Image

I've investigated the cause of this bug:
At runtime, if no files are uploaded, the value of the file list field in the payload from the frontend is "", whereas the correct value should be [].

error:
Image

correct
Image

✔️ Expected Behavior

if no files are uploaded, it correctly follows the logic where the file list is empty.

Actual Behavior

after publishing and running, if no files are uploaded, an error occurs.

Originally created by @CJack812 on GitHub (Apr 15, 2025). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce When adding a field that contains a file list to the workflow, and this field is optional. During debugging in the studio interface, if no files are uploaded, it correctly follows the logic where the file list is empty. However, after publishing and running, if no files are uploaded, an error occurs. Figure 1: Works correctly during debugging ![Image](https://github.com/user-attachments/assets/f0972594-789b-4666-b0c1-bd9710f8cfbb) Figure 2: Error occurs during execution ![Image](https://github.com/user-attachments/assets/506fabb4-07d2-41e0-9d46-cc86c379ff2b) I've investigated the cause of this bug: At runtime, if no files are uploaded, the value of the file list field in the payload from the frontend is `""`, whereas the correct value should be `[]`. error: ![Image](https://github.com/user-attachments/assets/03880865-fbe1-4c6b-bf73-2f2847908b41) correct ![Image](https://github.com/user-attachments/assets/6d79d0a4-10e1-467b-87da-cf886aa9bfae) ### ✔️ Expected Behavior if no files are uploaded, it correctly follows the logic where the file list is empty. ### ❌ Actual Behavior after publishing and running, if no files are uploaded, an error occurs.
yindo added the 🐞 buggood first issuecloud labels 2026-02-21 19:09:49 -05:00
yindo closed this issue 2026-02-21 19:09:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 15, 2025):

Hello @CJack812! I'm Dosu, your friendly bot here to help you tackle bugs, answer questions, and guide you toward becoming a contributor. While you're waiting for a human maintainer, feel free to let me know how I can assist you! 🐱👓

I found a similar unsolved discussion regarding the error "files in input form must be a list of files" when using "Run batch" in the workflow with template.csv [1].

For your issue, it seems that the problem arises because the file list field in the payload is being set to an empty string ("") instead of an empty array ([]) when no files are uploaded. This discrepancy between the debugging environment and the production environment might be causing the error.

To address this, you can try modifying the file /app/api/core/variables/variables.py in your Docker container by changing:

class ArrayFileVariable(ArrayFileSegment, Variable)

to:

class ArrayFileVariable(ArrayFileSegment, ArrayVariable)

After making this change, restart your Docker compose setup. This modification should help the file list field to properly work with iteration nodes in the workflow [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 15, 2025): <!-- Greeting --> Hello @CJack812! I'm [Dosu](https://dosu.dev), your friendly bot here to help you tackle bugs, answer questions, and guide you toward becoming a contributor. While you're waiting for a human maintainer, feel free to let me know how I can assist you! 🐱‍👓 <!-- Answer --> I found a similar unsolved discussion regarding the error "files in input form must be a list of files" when using "Run batch" in the workflow with `template.csv` <sup>[[1]](https://github.com/langgenius/dify/discussions/13005)</sup>. For your issue, it seems that the problem arises because the file list field in the payload is being set to an empty string (`""`) instead of an empty array (`[]`) when no files are uploaded. This discrepancy between the debugging environment and the production environment might be causing the error. To address this, you can try modifying the file `/app/api/core/variables/variables.py` in your Docker container by changing: ```python class ArrayFileVariable(ArrayFileSegment, Variable) ``` to: ```python class ArrayFileVariable(ArrayFileSegment, ArrayVariable) ``` After making this change, restart your Docker compose setup. This modification should help the file list field to properly work with iteration nodes in the workflow <sup>[[2]](https://github.com/langgenius/dify/issues/12048)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/611ce034-786c-4843-910a-0c70bdb5db2d?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Apr 15, 2025):

Already fixed in fix: do not submit value when file input is optional (#17861)

@crazywoola commented on GitHub (Apr 15, 2025): Already fixed in fix: do not submit value when file input is optional (#17861)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12949