{"record":{"id":"e5ee2854fdac6789","repo":"gofr-dev/gofr","slug":"unsupported-kind","errorCode":null,"errorMessage":"unsupported kind","messagePattern":"unsupported kind","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/http/multipart_file_bind.go","lineNumber":16,"sourceCode":"package http\n\nimport (\n\t\"errors\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"reflect\"\n\t\"strconv\"\n\n\t\"gofr.dev/pkg/gofr/file\"\n)\n\nvar (\n\terrUnsupportedInterfaceType = errors.New(\"unsupported interface value type\")\n\terrDataLengthExceeded       = errors.New(\"data length exceeds array capacity\")\n\terrUnsupportedKind          = errors.New(\"unsupported kind\")\n\terrSettingValueFailure      = errors.New(\"error setting value at index\")\n\terrNotAStruct               = errors.New(\"provided value is not a struct\")\n\terrUnexportedField          = errors.New(\"cannot set field; it might be unexported\")\n\terrUnsupportedFieldType     = errors.New(\"unsupported type for field\")\n\terrFieldsNotSet             = errors.New(\"no fields were set\")\n)\n\ntype formData struct {\n\tfields map[string][]string\n\tfiles  map[string][]*multipart.FileHeader\n}\n\nfunc (uf *formData) mapStruct(val reflect.Value, field *reflect.StructField) (bool, error) {\n\tvKind := val.Kind()\n\n\tif field == nil {\n\t\t// Check if val is not a struct\n\t\tif vKind != reflect.Struct {","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/http/multipart_file_bind.go#L1-L34","documentation":"errUnsupportedKind is returned by setSliceOrArrayValue when the element kind of a slice/array field in the bind target is not one of the kinds the multipart binder supports (e.g. trying to bind strings into a slice of maps, channels, or other complex kinds). Only basic kinds can be constructed from multipart string values.","triggerScenarios":"Binding multipart data into a struct field like []map[string]string, []chan int, or [][]byte-style composite element kinds unsupported by the binder.","commonSituations":"Overly ambitious DTOs with slices of nested complex types in multipart endpoints; reusing JSON-oriented structs (where UnmarshalJSON handles complex shapes) for multipart binding.","solutions":["Use slices of primitive types ([]string, []int, etc.) in multipart bind targets","Pre-process multipart values manually for complex element types instead of relying on automatic binding","Add a validation step that checks field kinds before binding and rejects unsupported shapes with a clear client message"],"exampleFix":"// before\ntype Upload struct { Items []map[string]string }\n// after\ntype Upload struct { ItemIDs []string }","handlingStrategy":"type-guard","validationCode":"// reject unsupported element kinds before binding\nif k := t.Field(i).Type.Elem().Kind(); k == reflect.Map || k == reflect.Chan || k == reflect.Struct { return errUnsupportedKind }","typeGuard":"func supportedSliceKind(t reflect.Type) bool {\n  if t.Kind() != reflect.Slice && t.Kind() != reflect.Array { return false }\n  switch t.Elem().Kind() {\n  case reflect.String, reflect.Int, reflect.Int64, reflect.Float64, reflect.Bool:\n    return true\n  }\n  return false\n}","tryCatchPattern":"if err := bind.Struct(&upload); err != nil { http.Error(w, err.Error(), http.StatusBadRequest); return }","preventionTips":["Bind only slices of primitives from multipart data","Handle nested/complex payloads via JSON request bodies instead","Validate struct field kinds in unit tests for bind targets"],"tags":["multipart","binding","reflection"],"backgroundTag":"unsupported-bind-type","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}