Repository navigation
fix(server): pass a Buffer req.body through as bytes in the node-http adapter - #8061
Conversation
… adapter
A raw body parser such as `express.raw()` leaves `req.body` as a Buffer.
`createBody` stringified it as JSON, so procedures got
`{"type":"Buffer","data":[...]}` instead of the request body: JSON inputs
failed validation and binary inputs got the wrong bytes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@krish-goradia is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
trpc-bot
left a comment
There was a problem hiding this comment.
A Buffer req.body now goes through as bytes, not as JSON.stringify output. Checked locally: both regression tests fail without the fix and pass with it.
Optional follow-up: req.body instanceof Uint8Array would also cover a plain Uint8Array.
Generated by Claude Code
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Why
app.use(express.raw({ type: '*/*' }))(common for webhook signature checks),req.bodyis a Buffer.JSON.stringifyon that Buffer, so procedures received{"type":"Buffer","data":[...]}. JSON inputs failed validation, andoctetInputParserinputs got the wrong bytes.What
incomingMessageToRequestnow passes a Bufferreq.bodythrough as bytes instead of stringifying it.express.raw()is no longer listed as breaking binary inputs; text parsers likeexpress.text()still do.Alternatives considered
express.raw()as unsupported. That would leave plain JSON calls broken too, which the docs never mentioned.Testing
packages/tests/server/regression/expressRawBodyParser.test.tsfails without the fix (the JSON mutation getsundefinedinput; the upload gets the JSON text of the Buffer) and passes with it.pnpm lint-fix,pnpm formatandpnpm typecheck-packagesare clean.AI model
Claude Opus 5.5
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit