Skip to content

fix(bind): restore []string values for map[string]interface{} duplicates#2982

Open
leno23 wants to merge 1 commit into
labstack:v4from
leno23:fix/multipart-map-interface-slice-binding
Open

fix(bind): restore []string values for map[string]interface{} duplicates#2982
leno23 wants to merge 1 commit into
labstack:v4from
leno23:fix/multipart-map-interface-slice-binding

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • Fix regression when binding multipart form data with duplicate field names to map[string]interface{}
  • Store a single value as string and multiple values as []string

Problem

Since v4.13.0, binding duplicate multipart fields like two ima_slice values to map[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:

  • one value → string
  • multiple values → []string

Test plan

  • Updated TestDefaultBinder_bindDataToMap
  • Added TestBindMultipartFormToMapInterface
  • go test ./... -run 'TestDefaultBinder_bindDataToMap|TestBindMultipartFormToMapInterface'

Fixes #2731

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>
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