zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
800 stars 403 forks source link

Multipart boundary generated by Body.fromMultipartFormUUID cannot be parsed by server #3117

Closed countfloyd closed 2 months ago

countfloyd commented 2 months ago

Have an ZClient calling another zio-http server endpoint with a multipart form and a auto-generated boundary:

body <- Body.fromMultipartFormUUID(
      Form(
        FormField.Simple("name", name),
        FormField.streamingBinaryField("upload", upload, MediaType.application.`octet-stream`, None, Some(fileName)),
      )
)

This generates a boundary of '(((random-uuid)))'. Passing this request with this boundary format is not parsed correctly by the zio-http server at the other end. I get an error:

400 POST /api/attachments 1194ms
timestamp=2024-09-09T22:58:40.380718Z level=INFO thread=#zio-fiber-940828076 message="Http request served" location=XXX.Main.run file=Main.scala line=81 method=POST duration_ms=1134 url=/api/attachments response_size=126 status_code=400 response="{"name":"MalformedBody","message":"Malformed request body failed to decode: Missing multipart/form-data field (Success(name)"}" content-type="multipart/form-data; boundary=(((71126f2f-0619-41dc-8914-86b0a1b318f0)))"

If I specify my own boundary value (i.e. --random-uuid), it works ok.

jdegoes commented 2 months ago

/bounty $125 for fix and test.

algora-pbc[bot] commented 2 months ago

💎 $125 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #3117 with your implementation plan
  2. Submit work: Create a pull request including /claim #3117 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @varshith257 Sep 10, 2024, 11:42:32 AM #3123
varshith257 commented 2 months ago

/attempt #3117

Algora profile Completed bounties Tech Active attempts Options
@varshith257    3 ZIO bounties
+ 7 bounties from 4 projects
TypeScript, Go
Cancel attempt
algora-pbc[bot] commented 2 months ago

💡 @varshith257 submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] commented 2 months ago

🎉🎈 @varshith257 has been awarded $125! 🎈🎊