fix(bind): restore []string values for map[string]interface{} duplicates#2982
fix(bind): restore []string values for map[string]interface{} duplicates#2982leno23 wants to merge 1 commit into
Conversation
When binding multipart/form-data to map[string]interface{}, store a single
value as string and multiple values as []string. This matches the behavior
before v4.13.0 and the intent of labstack#2656.
Fixes labstack#2731
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Heads-up for whoever reviews this: binding This PR re-introduces the slice behavior for the duplicate-key case, so it would re-break the same users #2656 was protecting. That may well be the right call for v5 (a major version is the place to change it) — just flagging that it's a deliberate backward-compat reversal, not a pure bugfix, so the decision is made consciously and noted in the v5 migration guide if accepted. |
Summary
map[string]interface{}stringand multiple values as[]stringProblem
Since v4.13.0, binding duplicate multipart fields like two
ima_slicevalues tomap[string]interface{}only kept the first value. Applications expecting a slice silently broke.This regressed after #2656, which intended to preserve pre-v4.12.0 single-string behavior but always bound
v[0].Fix
For
map[string]interface{}/map[string]any:string[]stringTest plan
TestDefaultBinder_bindDataToMapTestBindMultipartFormToMapInterfacego test ./... -run 'TestDefaultBinder_bindDataToMap|TestBindMultipartFormToMapInterface'Fixes #2731