Skip to content

fix: issue with header, validator - #67

Merged
moutonjeremy merged 4 commits into
mainfrom
fix/v3.3.1
Oct 19, 2026
Merged

moutonjeremy merged 4 commits into
mainfrom
fix/v3.3.1

Conversation

@moutonjeremy

Copy link
Copy Markdown
Member

No description provided.

moutonjeremy and others added 4 commits October 19, 2026 19:59
v3.3.0 decodes the body before binding the path, query and headers, but
the binders only overwrite the parameters present in the request. A
header-only field absent from the request kept the value the JSON
decoder took from a body key with the same name: Tenant
`header:"X-Tenant"` became "evil" with {"tenant":"evil"} and no header.
That defeats an application trusting a header set by a proxy, such as
X-User-Id.

After decoding the body, parseInput now resets the uri, query and header
fields that declare no body tag (json, form, xml, msgpack, cbor; "-"
counts as none), then binds them from the request. A field that also
declares a body tag keeps accepting either.

TestHeaderNotInRequestBody pinned the old behavior (a required header
satisfied from the body); it now expects 422.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HTTPStatus, ContentType and Error were declared on *Problem, so a Problem
passed by value (as TError or in OpenAPIOptions.Errors) implemented none
of them: the library fell back to a Code int field, found a string, and
served and documented a 500 in application/json. RawResponse had the
same flaw: by value it was not a Responder and got encoded as JSON.

The methods now have value receivers, so both work by value as well as
by pointer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A validator returning (nil, nil) made validateSecurityRequirement
dereference a nil AuthContext and panic when security schemes are
configured; with Bearer-only validation the request went on without a
context. Every scheme validator (Bearer, Basic, API key, AWS SigV4) now
turns such a result into an authentication failure, in routes and in the
standalone middlewares alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Path, query and header fields never come from the body, Problem works by
value, and a validator returning no context is a 401. The Method example
had its first two arguments swapped: the signature is
Method(router, method, path, handler, options).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moutonjeremy
moutonjeremy merged commit 01b501c into main Oct 19, 2026
4 checks passed
@moutonjeremy
moutonjeremy deleted the fix/v3.3.1 branch October 19, 2026 18:16
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