Skip to content

fix(server): ignore invalid headers in RequestHeadersPlugin - #2491

Merged
dinwwwh merged 3 commits into
1.xfrom
fix/1.x-request-headers-invalid-entries
Nov 18, 2026
Merged

dinwwwh merged 3 commits into
1.xfrom
fix/1.x-request-headers-invalid-entries

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 18, 2026

Copy link
Copy Markdown
Member

RequestHeadersPlugin now leaves out header entries that Headers rejects 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

  • Invalid header names and values are left out of context.reqHeaders.
  • Valid headers on the same request are kept.

Testing

  • Added a batch request test with invalid header names and values.
  • The request headers and batch plugin tests, lint, and the packages/server type check pass.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f400628-aaee-403c-a168-25b04d976a5e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
orpc 71f54d7 Nov 18 2026, 07:44 AM

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2491

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2491

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2491

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2491

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@2491

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@2491

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@2491

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2491

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2491

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2491

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@2491

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@2491

@orpc/experimental-pino

npm i https://pkg.pr.new/@orpc/experimental-pino@2491

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@2491

@orpc/experimental-publisher-durable-object

npm i https://pkg.pr.new/@orpc/experimental-publisher-durable-object@2491

@orpc/experimental-ratelimit

npm i https://pkg.pr.new/@orpc/experimental-ratelimit@2491

@orpc/react

npm i https://pkg.pr.new/@orpc/react@2491

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@2491

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@2491

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2491

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2491

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@2491

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@2491

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@2491

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@2491

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@2491

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@2491

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@2491

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@2491

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2491

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2491

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2491

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@2491

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@2491

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2491

commit: 96e14f7

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 — toSafeFetchHeaders keeps the existing toFetchHeaders path and, when it throws, rebuilds the Headers one entry at a time, dropping only the entries Headers.append rejects. Per-item granularity means a valid value for a name survives an invalid sibling (covered by x-mixed).
  • Regression test — a batch request mixing invalid names ('a b', ''), invalid values (CR/LF, non-latin1, an object whose toString is not callable) and valid headers asserts 207 plus the exact surviving reqHeaders. I ran it locally: 4/4 pass.
  • No CSRF interaction — SimpleCsrfProtectionHandlerPlugin reads request.headers directly rather than context.reqHeaders, so omitting invalid entries cannot weaken it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — the test job installs Node 22 between checkout and pnpm/action-setup@v6, and drops the post-install pnpm runtime set node 22 step, so pnpm i compiles better-sqlite3 against the same ABI the tests run on.
  • Verified against CI — on 71f54d78 the test job is green (setup-node, pnpm i and pnpm run test:coverage all succeed), where f9c6f438 still failed it with the same better-sqlite3 "Module did not self-register" ABI error. publish-commit is 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit 738ee3e into 1.x Nov 18, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant