Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Request with sys.file in Form-Data Results in Empty Files #12752

Closed
5 tasks done
11qqq-dr opened this issue Jan 15, 2025 · 4 comments
Closed
5 tasks done

HTTP Request with sys.file in Form-Data Results in Empty Files #12752

11qqq-dr opened this issue Jan 15, 2025 · 4 comments
Labels
🐞 bug Something isn't working

Comments

@11qqq-dr
Copy link

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

0.15.1

Cloud or Self Hosted

Cloud, Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Issue Description:
When making an HTTP request using sys.file as a parameter with form-data format, the file content is always empty. However, when switching to the file format, a single file can be successfully sent. This issue is easy to reproduce by simply using sys.file under an HTTP request. I’m using version 0.15.1.

I have encountered this issue both on cloud and self-hosted setups.
Create an HTTP request that uses sys.file as a parameter.
Select form-data as the request format.
Observe that the file content is empty.
Switch to file format and verify that the file can be sent successfully.

✔️ Expected Behavior

Files should be properly sent when using sys.file with form-data.

❌ Actual Behavior

Files are empty when using sys.file with form-data.

Copy link

dosubot bot commented Jan 15, 2025

Hello @11qqq-dr! I'm here to help you with any bugs, questions, or contributions you may have. Let's tackle this issue together!

The issue you're experiencing with sys.file in form-data requests resulting in empty files, while switching to the file format works, is likely due to how the file data is being handled and attached to the request. In the Dify codebase, the handling of file content for form-data requests involves downloading the file and preparing it for inclusion in the HTTP request. If this process is not correctly implemented, it could lead to empty files being sent [1].

The _init_body method in the Executor class processes file data by downloading the file content and constructing a dictionary with the file name, content, and MIME type. If there's an issue in this process, it might result in the file content not being properly attached [2].

To address this, you might want to check the implementation of file handling in your setup or consider using the file format as a workaround until the issue is resolved.

To continue talking to Dosu, mention @dosu.


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

@dosubot dosubot bot added the 🐞 bug Something isn't working label Jan 15, 2025
@11qqq-dr
Copy link
Author

@dosu

Copy link

dosubot bot commented Jan 16, 2025

Hey @11qqq-dr! It looks like you're trying to reach out, but I'm not quite sure what you need help with. I'm here to assist with bugs, technical questions, and engineering knowledge. If there's something specific you need, feel free to ask! If you think I should have answered this request, you can always reach out to the Dosu Team. 😊

To continue talking to Dosu, mention @dosu.


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

@crazywoola
Copy link
Member

sys.files is Array[File], however the HTTP node form-data accepts File, so this is a type mismatch error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants