gofiber/fiber · error

unsupported value type: %T

Error message

unsupported value type: %T

What it means

In binder/mapping.go, when value is a string the function expects data to be map[string][]string; it asserts `any(data).(map[string][]string)`. If the assertion fails (data is some other map or non-map type), it returns fmt.Errorf("unsupported value type: %T", value). Note: the message formats value's type but the actual mismatch is on data.

Solutions

  1. Pass data as map[string][]string when invoking the mapping helper.
  2. Use the public binder APIs rather than internal mapping functions.
  3. Add a type assertion on data before binding so the failure surface is explicit.

Example fix

// before
data := map[string]string{"k": "v"}     // wrong element type
binder.Map(data, out, ...)

// after
data := map[string][]string{"k": {"v"}}
binder.Map(data, out, ...)
Defensive patterns

Strategy: type-guard

Validate before calling

dm, ok := any(data).(map[string][]string)
if !ok { return errors.New("data must be map[string][]string") }

Type guard

func isStringDataMap(data any) bool {
    _, ok := data.(map[string][]string)
    return ok
}

Prevention

When it happens

Trigger: Calling the internal mapping helper with a data argument that is not map[string][]string while the value being assigned is a string. Typically reached only via custom bind sources or direct calls into binder internals.

Common situations: Custom binder extensions passing the wrong data shape; user-defined bind helpers that bypass the standard pipeline; integrations that build their own data maps with different value element types.

Related errors


AI-assisted analysis of gofiber/fiber@a105acad6c (2026-08-11). Data as JSON: /api/errors/7f6bd2cf125d3925. Report an issue: GitHub.

Appendix: source

Thrown at binder/mapping.go:373

		return content[:i]
	}
	return content
}

func formatBindData[T, K any](aliasTag string, out any, data map[string][]T, key string, value K, enableSplitting, supportBracketNotation bool) error { //nolint:revive // it's okay
	var err error
	if supportBracketNotation && strings.IndexByte(key, '[') >= 0 {
		key, err = parseParamSquareBrackets(key)
		if err != nil {
			return err
		}
	}

	switch v := any(value).(type) {
	case string:
		dataMap, ok := any(data).(map[string][]string)
		if !ok {
			return fmt.Errorf("unsupported value type: %T", value)
		}

		assignBindData(aliasTag, out, dataMap, key, v, enableSplitting)
	case []string:
		dataMap, ok := any(data).(map[string][]string)
		if !ok {
			return fmt.Errorf("unsupported value type: %T", value)
		}

		for _, val := range v {
			assignBindData(aliasTag, out, dataMap, key, val, enableSplitting)
		}
	case []*multipart.FileHeader:
		for _, val := range v {
			valT, ok := any(val).(T)
			if !ok {
				return fmt.Errorf("unsupported value type: %T", value)
			}

View on GitHub (pinned to a105acad6c)