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 Post form-data does not work with file (Could not parse multipart form) #10694

Closed
5 tasks done
saendu opened this issue Nov 14, 2024 · 7 comments · Fixed by #10695
Closed
5 tasks done

HTTP Post form-data does not work with file (Could not parse multipart form) #10694

saendu opened this issue Nov 14, 2024 · 7 comments · Fixed by #10695
Assignees
Labels
🐞 bug Something isn't working

Comments

@saendu
Copy link

saendu commented Nov 14, 2024

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.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. create a flow with a file param
  2. create a HTTP Post node with form-data
  3. attach file to form data
  4. try to send multipart form to server
image

✔️ Expected Behavior

Correct parsing of multipart form. Adding Content-Disposition file to form-data.

❌ Actual Behavior

Form-data is not correctly parsed. Content-Disposition data 'file' is missing.

POST /v1/audio/transcriptions HTTP/1.1 
Host: api.openai.com 
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarymriqkhpjloahvxub 
Authorization: ***************************************************************************************************************************************************************************
 
------WebKitFormBoundarymriqkhpjloahvxub 
Content-Disposition: form-data; name="model" 
 
whisper-1 
------WebKitFormBoundarymriqkhpjloahvxub 
Content-Disposition: form-data; name="" 
 
 
------WebKitFormBoundarymriqkhpjloahvxub-- 

`

Error from server: Could not parse multipart form
"status_code": 400,
  "body": "{\n    \"error\": {\n        \"message\": \"Could not parse multipart form\",\n        \"type\": \"invalid_request_error\",\n        \"param\": null,\n        \"code\": null\n    }\n}\n",
@dosubot dosubot bot added the 🐞 bug Something isn't working label Nov 14, 2024
Copy link

dosubot bot commented Nov 14, 2024

I found two similar discussions that might be relevant to your issue:

  1. How to use API to upload file in 0.11.0 - This discussion is still open and might contain insights or solutions related to file uploads in Dify version 0.11.0 [1].

  2. How can I upload with multiple files to another server to handle? - This is another open discussion that might provide useful information on handling file uploads [2].

For your specific issue, ensure that the Content-Disposition header is correctly set for the file in your multipart form-data. The name attribute should be specified, and the file should be included with a proper filename attribute. Here's an example of how it should look:

Content-Disposition: form-data; name="file"; filename="yourfile.txt"

Make sure that the file is being correctly attached in the form-data and that the server expects the file under the correct parameter name. If the issue persists, reviewing the discussions linked above might provide additional context or solutions.

To continue talking to Dosu, mention @dosu.

@hjlarry hjlarry mentioned this issue Nov 14, 2024
5 tasks
@crazywoola
Copy link
Member

This pull request #10695 can resolve part of you problems, but it still does not fix current behavior.

@saendu
Copy link
Author

saendu commented Nov 14, 2024

This pull request #10695 can resolve part of you problems, but it still does not fix current behavior.

Can you specify 'part of my problem'?

@crazywoola
Copy link
Member

crazywoola commented Nov 14, 2024

This pull request #10695 can resolve part of you problems, but it still does not fix current behavior.

Can you specify 'part of my problem'?

You can use this new tool to get the transcriptions from the OpenAI instead of using the HTTP Node.

@saendu
Copy link
Author

saendu commented Nov 15, 2024

This pull request #10695 can resolve part of you problems, but it still does not fix current behavior.

Can you specify 'part of my problem'?

You can use this new tool to get the transcriptions from the OpenAI instead of using the HTTP Node.

Ok thanks. I guess this will be released with the next release?
About the HTTP Post form-data. The strange thing about this bug is, it worked a couple of releases ago.

@laipz8200
Copy link
Member

Hi @saendu. Could you provide a minimal dsl to reproduce this issue? I tried in our Cloud service by sending a text file to httpbin.org, and it works well.

@saendu
Copy link
Author

saendu commented Nov 20, 2024

I've upgraded to 0.11.2 and it seems to work again. Cannot reproduce the bug anymore. You can close. Thanks!

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

Successfully merging a pull request may close this issue.

3 participants