Skip to content

fix(bind): reject unsupported map value types (#3235) - #3238

Merged
vishr merged 1 commit into
masterfrom
fix/bind-map-values
Nov 20, 2026
Merged

vishr merged 1 commit into
masterfrom
fix/bind-map-values

Conversation

@vishr

@vishr vishr commented Nov 20, 2026

Copy link
Copy Markdown
Member

Fixes #3235. Supersedes #3236. Thanks to @its-ernest for the report and the first fix, which is credited as co-author.

What changed

  • bindData now returns an error when path, query, header, or form data is bound into a map whose value type is not string, []string, or any. Before, these values were silently skipped.
  • Named string key types are now converted. Named string value types used to panic in SetMapIndex; they now return the same error.
  • DefaultBinder.Bind ignores that error when a JSON or XML body will be decoded into the map. So map[string]int on a route with path params and a JSON body still binds (fix(bind): return error for unsupported map value types- #7⁠ #3236 returned 400 there).

Behavior change

Calling BindPathValues, BindQueryParams, or BindHeaders directly with an unsupported map type now returns 400 instead of nil. c.Bind into such a map with path or query params and no body also returns 400 now.

Testing

go test -race ./... passes.

🤖 Generated with Claude Code

Binding path, query, header, or form data into a map whose value type is
not string, []string, or any used to skip silently, and named string
types panicked in SetMapIndex. bindData now returns an error for these
destinations. DefaultBinder.Bind ignores that error when a JSON or XML
body will be decoded into the map, so map[string]int with path params
and a JSON body still binds.

Fixes #3235
Supersedes #3236

Co-authored-by: its-ernest <204517848+its-ernest@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vishr
vishr merged commit fbd734f into master Nov 20, 2026
11 checks passed
@vishr
vishr deleted the fix/bind-map-values branch November 20, 2026 15:20
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.

[bug] bindData silently ignores map destinations with unsupported value types

1 participant