gin-gonic/gin · error

%s is not supported in the collection_format. (multi, csv, s

Error message

%s is not supported in the collection_format. (multi, csv, ssv, tsv, pipes)

What it means

Returned by trySplit (binding/form_mapping.go:230) when a struct field carries a collection_format tag whose value is not one of the supported separators (multi, csv, ssv, tsv, pipes). The tag controls how a single form value is split into slice/array elements.

Source

Thrown at binding/form_mapping.go:230

func trySplit(vs []string, field reflect.StructField) (newVs []string, err error) {
	cfTag := field.Tag.Get("collection_format")
	if cfTag == "" || cfTag == "multi" {
		return vs, nil
	}

	var sep string
	switch cfTag {
	case "csv":
		sep = ","
	case "ssv":
		sep = " "
	case "tsv":
		sep = "\t"
	case "pipes":
		sep = "|"
	default:
		return vs, fmt.Errorf("%s is not supported in the collection_format. (multi, csv, ssv, tsv, pipes)", cfTag)
	}

	totalLength := 0
	for _, v := range vs {
		totalLength += strings.Count(v, sep) + 1
	}
	newVs = make([]string, 0, totalLength)
	for _, v := range vs {
		newVs = append(newVs, strings.Split(v, sep)...)
	}

	return newVs, nil
}

func setByForm(value reflect.Value, field reflect.StructField, form map[string][]string, tagValue string, opt setOptions) (isSet bool, err error) {
	vs, ok := form[tagValue]
	if !ok && !opt.isDefaultExists {
		return false, nil

View on GitHub (pinned to 34dac209ff)

Solutions

  1. Use one of the supported values: multi (default, no split), csv (comma), ssv (space), tsv (tab), pipes (|).
  2. Remove the collection_format tag entirely if multi behaviour is what you want.
  3. Double-check spelling and case — values are lowercase and exact.

Example fix

// before
type Q struct {
    Tags []string `form:"tags" collection_format:"comma"`
}
// after
type Q struct {
    Tags []string `form:"tags" collection_format:"csv"`
}
Defensive patterns

Strategy: validation

Validate before calling

var validCF = map[string]bool{"": true, "multi": true, "csv": true, "ssv": true, "tsv": true, "pipes": true}
// at startup, walk struct tags:
func checkCollectionFormatTags(t reflect.Type) error {
    for i := 0; i < t.NumField(); i++ {
        cf := t.Field(i).Tag.Get("collection_format")
        if cf != "" && !validCF[cf] {
            return fmt.Errorf("field %s has invalid collection_format %q", t.Field(i).Name, cf)
        }
    }
    return nil
}

Try / catch

if err := c.ShouldBind(&q); err != nil {
    if strings.Contains(err.Error(), "is not supported in the collection_format") {
        // fix the tag to one of multi|csv|ssv|tsv|pipes
    }
}

Prevention

When it happens

Trigger: Tagging a slice/array field with collection_format:"comma" (should be csv), collection_format:"pipe" (should be pipes), collection_format:"json", or a typo like collection_format:"CSV".

Common situations: Copy-paste from OpenAPI spec names that differ from Gin's tag values; case mismatch (CSV vs csv); leftover tag from a different framework.

Related errors


AI-assisted analysis of gin-gonic/gin@34dac209ff (2026-08-04). Data as JSON: /data/errors/d35c75e6c2a1d475.json. Report an issue: GitHub.