Fix FormData boundary mismatch in OFetch client #2940
Draft
+128
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The OFetch client was sending multipart/form-data requests with mismatched boundaries: the Content-Type header specified one boundary while the request body used another, causing servers to reject requests with "0 elements" errors.
Root Cause
When creating a
Requestobject with FormData, the browser auto-generates a boundary and sets Content-Type. The code then copied this header to ofetch options while passing the original FormData as the body. Ofetch generated a new boundary for the FormData, creating a mismatch:Changes
applyRequestInterceptors()to acceptbodyparameter and delete Content-Type when body is FormDataThis allows ofetch to set its own Content-Type with the correct boundary that matches the actual request body it generates.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.