New Upload File can't work when an OPTIONAL input is unset or is set with URL. #6387

Closed
opened 2026-02-21 18:15:30 -05:00 by yindo · 1 comment
Owner

Originally created by @xfanwu on GitHub (Oct 28, 2024).

Originally assigned to: @laipz8200 on GitHub.

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

Cloud latest

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Create a chatflow
  2. Add a custom input field with Single File
  3. Check Image as the input type
  4. Make the variable Optional
  5. Enable Vision and select the variable set before in the sequence node
  6. Make any query in the preview without any image upload
  7. Error comes out: Run failed: Invalid variable type: <class 'core.variables.segments.NoneSegment'>
  8. If I put an image Url into the field, another error: No matching enum found for value ''
  9. The chatflow only works if I upload an image from local.
image image image image

✔️ Expected Behavior

Just make it work.

Actual Behavior

Please see the reproduce steps above.

Originally created by @xfanwu on GitHub (Oct 28, 2024). Originally assigned to: @laipz8200 on GitHub. ### 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 Cloud latest ### Cloud or Self Hosted Cloud ### Steps to reproduce 1. Create a chatflow 2. Add a custom input field with Single File 3. Check Image as the input type 4. Make the variable Optional 5. Enable Vision and select the variable set before in the sequence node 6. Make any query in the preview without any image upload 7. Error comes out: `Run failed: Invalid variable type: <class 'core.variables.segments.NoneSegment'>` 8. If I put an image Url into the field, another error: `No matching enum found for value ''` 9. The chatflow only works if I upload an image from local. <img width="495" alt="image" src="https://github.com/user-attachments/assets/704ca89a-452c-4c9b-ac58-069ad30b8e29"> <img width="440" alt="image" src="https://github.com/user-attachments/assets/b5b516f9-406f-4dc6-b5c1-aa6d232cb387"> <img width="1919" alt="image" src="https://github.com/user-attachments/assets/ef7b54a1-0865-4ff5-9d87-f6d049bf685e"> <img width="474" alt="image" src="https://github.com/user-attachments/assets/dab75263-d20a-4c33-9657-492659a48107"> ### ✔️ Expected Behavior Just make it work. ### ❌ Actual Behavior Please see the reproduce steps above.
yindo added the 🐞 bug label 2026-02-21 18:15:30 -05:00
yindo closed this issue 2026-02-21 18:15:31 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 28, 2024):

The issue you're encountering seems to be related to how Dify handles optional file inputs when they are left unset or when a URL is provided instead of a local file upload.

  1. Unset Optional Input: When an optional file input is left unset, the system is encountering an error due to the NoneSegment being used. This segment is meant to handle None values, but if the system expects a different type of segment, it can lead to errors like the one you're seeing: Invalid variable type: <class 'core.variables.segments.NoneSegment'> [1].

  2. URL Input: When a URL is provided, the error No matching enum found for value '' suggests that the system is not correctly handling the URL input type. This might be due to the system expecting a specific enum value for file types, and the URL input is not being processed correctly to match these expected values [2].

To address these issues, you might need to ensure that the system is configured to handle None values gracefully for optional inputs and that URL inputs are correctly validated and matched against the expected file type enums. This might involve checking the configuration or logic that processes these inputs in the chatflow setup.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 28, 2024): <!-- Answer --> The issue you're encountering seems to be related to how Dify handles optional file inputs when they are left unset or when a URL is provided instead of a local file upload. 1. **Unset Optional Input**: When an optional file input is left unset, the system is encountering an error due to the `NoneSegment` being used. This segment is meant to handle `None` values, but if the system expects a different type of segment, it can lead to errors like the one you're seeing: `Invalid variable type: <class 'core.variables.segments.NoneSegment'>` <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/variables/segments.py)</sup>. 2. **URL Input**: When a URL is provided, the error `No matching enum found for value ''` suggests that the system is not correctly handling the URL input type. This might be due to the system expecting a specific enum value for file types, and the URL input is not being processed correctly to match these expected values <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/file/enums.py)</sup>. To address these issues, you might need to ensure that the system is configured to handle `None` values gracefully for optional inputs and that URL inputs are correctly validated and matched against the expected file type enums. This might involve checking the configuration or logic that processes these inputs in the chatflow setup. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6387