Ignore undeclared headers in strict HttpApi header decoding - #8557
Closed
BleedingDev wants to merge 1 commit into
Closed
BleedingDev wants to merge 1 commit into
BleedingDev wants to merge 1 commit into
Conversation
HTTP header maps always carry transport headers such as content-type and user-agent, so annotating an API with onExcessProperty "error" rejected every request that declared a headers schema, and every client response decoded through WithHeaders. Header codecs now drop the option, while payload, params, query and body codecs stay strict. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 39c6d4c The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
This branch is waiting to be deployed
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.
Follow-up to #8269
Why the change
With
HttpApi.ParseOptionsset to{ onExcessProperty: "error" }, every endpoint orWithHeadersresponse that declares headers failed on real traffic because header maps always carry transport headers likecontent-type, so header decoding now drops undeclared headers while payload, params, query and body stay strict.Special things to note
undefined) rather than set to"ignore", so structs keep their default-options fast path.ParseOptionsdocs caveat now describes the new behaviour instead of warning about it.Change outline
One shared helper, used at every place a header map is decoded:
Where it is applied:
Behaviour under a strict API:
Tests
HttpApiBuilder: strict API with a declaredx-tenantheader accepts extra transport headers, passes onlyx-tenantto the handler, and still rejects an extra payload key.HttpApiClient: strict API decodes buffered and streamedWithHeadersresponses that also carrycontent-type.Both tests fail on
main.pnpm check,pnpm circular, lint and thehttpapitest suite pass locally. Changeset:effectpatch.🤖 Generated with Claude Code