{"id":"f9df1aae7be5c830","repo":"labstack/echo","slug":"unknown-type","errorCode":null,"errorMessage":"unknown type","messagePattern":"unknown type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bind.go","lineNumber":400,"sourceCode":"\t\treturn setUintField(val, 0, structField)\n\tcase reflect.Uint8:\n\t\treturn setUintField(val, 8, structField)\n\tcase reflect.Uint16:\n\t\treturn setUintField(val, 16, structField)\n\tcase reflect.Uint32:\n\t\treturn setUintField(val, 32, structField)\n\tcase reflect.Uint64:\n\t\treturn setUintField(val, 64, structField)\n\tcase reflect.Bool:\n\t\treturn setBoolField(val, structField)\n\tcase reflect.Float32:\n\t\treturn setFloatField(val, 32, structField)\n\tcase reflect.Float64:\n\t\treturn setFloatField(val, 64, structField)\n\tcase reflect.String:\n\t\tstructField.SetString(val)\n\tdefault:\n\t\treturn errors.New(\"unknown type\")\n\t}\n\treturn nil\n}\n\nfunc unmarshalInputsToField(valueKind reflect.Kind, values []string, field reflect.Value) (bool, error) {\n\tif valueKind == reflect.Pointer {\n\t\tif field.IsNil() {\n\t\t\tfield.Set(reflect.New(field.Type().Elem()))\n\t\t}\n\t\tfield = field.Elem()\n\t}\n\n\tfieldIValue := field.Addr().Interface()\n\tunmarshaler, ok := fieldIValue.(bindMultipleUnmarshaler)\n\tif !ok {\n\t\treturn false, nil\n\t}\n\treturn true, unmarshaler.UnmarshalParams(values)","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/labstack/echo/blob/05489dc1730161df26b72d1ae2a3ba6fb8178fc7/bind.go#L382-L418","documentation":"Returned by setWithProperType in its default switch case when the destination field's reflect.Kind is not one of the supported scalar kinds (int/uint variants, bool, float32/64, string, pointer) and the field does not implement BindUnmarshaler or encoding.TextUnmarshaler. The binder has no logic to assign a string input to types like complex64, chan, func, map, array, or a nested struct.","triggerScenarios":"Binding a query/form/param/header value into a struct field whose type is complex64, a channel, a func, a map, an array, or a nested struct lacking a custom unmarshaler. Example: type Req struct{ C complex64 `query:\"c\"` }.","commonSituations":"Using uncommon numeric types (complex) in request DTOs. Having a field of type map[string]string or a nested struct expecting automatic conversion from a flat string param.","solutions":["Implement echo.BindUnmarshaler (UnmarshalParam) or encoding.TextUnmarshaler (UnmarshalText) on the field's type","Change the field type to a supported scalar (string, int, float64) and convert it manually in the handler","For nested data, bind from JSON body instead of flat query/form params"],"exampleFix":"// before\ntype Req struct {\n    Matrix [4]float64 `query:\"matrix\"`\n}\n\n// after\ntype Req struct {\n    Matrix string `query:\"matrix\"`\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Ensure field types are supported by the binder\nvar supportedKinds = map[reflect.Kind]bool{\n    reflect.Int: true, reflect.Int8: true, reflect.Int16: true,\n    reflect.Int32: true, reflect.Int64: true,\n    reflect.Uint: true, reflect.Uint8: true, reflect.Uint16: true,\n    reflect.Uint32: true, reflect.Uint64: true,\n    reflect.Bool: true, reflect.Float32: true, reflect.Float64: true,\n    reflect.String: true, reflect.Pointer: true, reflect.Slice: true,\n}\nfunc hasUnsupportedFieldTypes(rt reflect.Type) error {\n    for i := 0; i < rt.NumField(); i++ {\n        f := rt.Field(i)\n        if hasBindTag(f.Tag) && !supportedKinds[f.Type.Kind()] {\n            return fmt.Errorf(\"field %s has unsupported kind %s\", f.Name, f.Type.Kind())\n        }\n    }\n    return nil\n}","tryCatchPattern":"if err := c.Bind(&req); err != nil {\n    if strings.Contains(err.Error(), \"unknown type\") {\n        return echo.NewHTTPError(http.StatusBadRequest, \"unsupported field type in request struct\")\n    }\n    return err\n}","preventionTips":["Stick to scalar types and slices of scalars for query/form/header binding","Implement BindUnmarshaler or TextUnmarshaler for any custom field type","Use JSON body binding for complex/nested data structures"],"tags":["binding","reflection","type-conversion","unsupported-type"],"analyzedSha":"05489dc1730161df26b72d1ae2a3ba6fb8178fc7","analyzedAt":"2026-08-04T21:32:47.783Z","schemaVersion":2}