Repository navigation
fix(bind): skip empty scalar header values - #3223
Merged
Merged
Conversation
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.
Summary
Fixes #3169.
BindHeadersindexes nil or zero-length header value slices when binding scalar map values or tagged struct fields. Treat entries with no values as absent for those destinations, while preserving slice-map values and custom multi-value unmarshalling.Related: #3170, #3171, #3175, and #3178. This version preserves
map[string][]stringentries and passes empty values to customUnmarshalParamsimplementations. It also avoids allocating ordinary pointer fields for absent values.Evidence
TestBindHeadersEmptyValuespanics on nil and empty slices for tagged structs,map[string]string, andmap[string]any.After: existing scalar values remain unchanged, one empty string still binds, slice-map values survive, ordinary pointer fields stay nil, and custom multi-value unmarshalling is still called.
GOTOOLCHAIN=go1.27.4 go test -race ./...,go vet ./...,golint -set_exit_status ./..., and current staticcheck pass.Merge Danger
Door: two-way
Blast Radius: binding
The shared binder skips scalar entries with no values. The reported header state requires in-process construction or mutation; this PR does not claim a remotely exploitable denial of service.