Skip to content

fix(bind): return error for unsupported map value types- #7⁠ - #3236

Open
its-ernest wants to merge 2 commits into
labstack:masterfrom
its-ernest:fix/bind-unsupported-map-value-types
Open

its-ernest wants to merge 2 commits into
labstack:masterfrom
its-ernest:fix/bind-unsupported-map-value-types

Conversation

@its-ernest

Copy link
Copy Markdown

Summary

Fixes #3235.

bindData silently returned nil for map destinations whose value type is not string, []string or any, leaving the destination untouched while reporting success. It now returns a descriptive error instead.

Behavior change

Binding to an unsupported map value type (for example map[string]int) now returns 400 Bad Request through BindQueryParams / BindPathValues / BindHeaders / form binding, rather than silently succeeding without binding.

Test plan

  • go test ./...
  • Updated TestDefaultBinder_bindDataToMap to assert the error for map[string]int and map[string][]int (with and without a nil map)

Binding to a map whose value type is not string, []string or any
silently returned nil and left the destination untouched. Return a
descriptive error instead.

Fixes #1
Add public API tests for supported map destinations and for map
destinations with unsupported value types via query and header binding.
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