Repository navigation
fix(server): ignore invalid headers in RequestHeadersPlugin - #2491
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
orpc | 71f54d7 | Nov 18 2026, 07:44 AM |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/experimental-pino
@orpc/experimental-publisher
@orpc/experimental-publisher-durable-object
@orpc/experimental-ratelimit
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fastify
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
ℹ️ One optional simplification inline. The fix itself is correct, and the new test exercises the failure path end to end.
Approach: sound — batch subrequest headers come from the request body, so Headers.append validation is the only thing standing between a client and a throw; catching it at the one place the server materializes Headers from request headers (RequestHeadersPlugin) fixes the crash without touching the client or the shared toFetchHeaders helper, which is still strict where strictness matters.
Reviewed changes
- Tolerant header conversion —
toSafeFetchHeaderskeeps the existingtoFetchHeaderspath and, when it throws, rebuilds theHeadersone entry at a time, dropping only the entriesHeaders.appendrejects. Per-item granularity means a valid value for a name survives an invalid sibling (covered byx-mixed). - Regression test — a batch request mixing invalid names (
'a b',''), invalid values (CR/LF, non-latin1, an object whosetoStringis not callable) and valid headers asserts207plus the exact survivingreqHeaders. I ran it locally: 4/4 pass. - No CSRF interaction —
SimpleCsrfProtectionHandlerPluginreadsrequest.headersdirectly rather thancontext.reqHeaders, so omitting invalid entries cannot weaken it.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — pinning Node 22 with actions/setup-node before pnpm i is the placement that actually aligns install lifecycle scripts with the test runtime; the pnpm runtime set node 22 step it replaces could not, whichever order it ran in.
Reviewed changes — since the prior pullfrog review, one commit (71f54d78):
- Node pinned via
actions/setup-node@v7— thetestjob installs Node 22 between checkout andpnpm/action-setup@v6, and drops the post-installpnpm runtime set node 22step, sopnpm icompilesbetter-sqlite3against the same ABI the tests run on. - Verified against CI — on
71f54d78thetestjob is green (setup-node,pnpm iandpnpm run test:coverageall succeed), wheref9c6f438still failed it with the samebetter-sqlite3"Module did not self-register" ABI error.publish-commitis green as well; the header fix and its test are unchanged by this commit.
The previously raised simplification on toSafeFetchHeaders has been withdrawn, so nothing blocks this PR.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

RequestHeadersPluginnow leaves out header entries thatHeadersrejects instead of throwing. Batch subrequest headers come from the request body, so they can contain names and values an HTTP parser would not accept.Fixes
context.reqHeaders.Testing
packages/servertype check pass.