Fix file upload regression: restore multipart request data processor#2704
Merged
mbroshi-stripe merged 3 commits intomasterfrom May 6, 2026
Merged
Fix file upload regression: restore multipart request data processor#2704mbroshi-stripe merged 3 commits intomasterfrom
mbroshi-stripe merged 3 commits intomasterfrom
Conversation
jar-stripe
approved these changes
May 5, 2026
Contributor
jar-stripe
left a comment
There was a problem hiding this comment.
LGTM; please double check that the test is using the correct class before merging
There was a problem hiding this comment.
Pull request overview
Fixes a regression in the /v1/files resource introduced during the v22 class-based resource migration, where file uploads stopped being encoded as multipart/form-data and were instead URL-encoded.
Changes:
- Restored
requestDataProcessor = multipartRequestDataProcessoronFileResourceso file uploads are encoded viamultipartDataGenerator()again. - Added a regression test asserting that
stripe.files.create()produces a multipart-encoded request body (captured as aUint8ArraycontainingContent-Disposition: form-data).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/resources/Files.spec.js | Adds a regression test to ensure file upload bodies are multipart/form-data encoded. |
| src/resources/Files.ts | Re-enables multipart request processing for FileResource uploads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Buffer.from().toString() is more idiomatic for Node.js tests and avoids potential TextDecoder edge cases with binary data. Co-Authored-By: Claude Opus 4.6 <[email protected]> Committed-By-Agent: claude
The SDK uses TextEncoder/TextDecoder everywhere (not Buffer) for cross-platform compatibility. Tests should follow the same pattern. Co-Authored-By: Claude Opus 4.6 <[email protected]> Committed-By-Agent: claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
File uploads to
/v1/filesbroke in v22 (works in v21). WhenFileResourcewasconverted from
StripeResource.extend({...})to a class-based pattern in #2619,the
requestDataProcessor = multipartRequestDataProcessorassignment was dropped.Without it, file upload POST bodies go through
queryStringifyRequestData()insteadof
multipartDataGenerator(), producing malformed request bodies that the Stripe APIrejects with 400 "Invalid request (check your POST parameters)".
What?
requestDataProcessor = multipartRequestDataProcessoronFileResource(a
Uint8Arraycontaining properContent-Disposition: form-dataheaders)See Also
Changelog
StripeInvalidRequestErroron the/v1/filesendpoint since v22.