{"record":{"id":"c23199e4d973317d","repo":"redis/go-redis","slug":"redis-scan-unsupported-s","errorCode":null,"errorMessage":"redis.Scan(unsupported %s)","messagePattern":"redis\\.Scan\\(unsupported (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hscan/hscan.go","lineNumber":206,"sourceCode":"\tf.SetFloat(v)\n\treturn nil\n}\n\nfunc decodeString(f reflect.Value, s string) error {\n\tf.SetString(s)\n\treturn nil\n}\n\nfunc decodeSlice(f reflect.Value, s string) error {\n\t// []byte slice ([]uint8).\n\tif f.Type().Elem().Kind() == reflect.Uint8 {\n\t\tf.SetBytes([]byte(s))\n\t}\n\treturn nil\n}\n\nfunc decodeUnsupported(v reflect.Value, s string) error {\n\treturn fmt.Errorf(\"redis.Scan(unsupported %s)\", v.Type())\n}\n","sourceCodeStart":188,"sourceCodeEnd":208,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/internal/hscan/hscan.go#L188-L208","documentation":"When decoding a Redis hash value into a struct field, hscan assigns a decoder per field type. Fields whose Go type has no registered decoder (e.g. nested structs, maps, bool arrays, complex numbers) get decodeUnsupported, which returns 'redis.Scan(unsupported <type>)'. The field is left untouched.","triggerScenarios":"Scanning an HGETALL result into a struct containing a field of an unsupported kind — e.g. a nested struct, a map, a time.Time without an appropriate hook, a slice of non-bytes, or a pointer field.","commonSituations":"Struct fields for JSON blobs stored as Redis strings (need manual unmarshal); nested objects; custom types without a registered codec.","solutions":["Change the field type to a supported one (string, numeric, []byte, bool, time.Duration, slice of these)","Store JSON in a string field and json.Unmarshal it separately after Scan","Register a custom decoder if the library's extension point allows it","Flatten nested structs into simple fields"],"exampleFix":"// before\ntype Config struct {\n\tMeta map[string]string `redis:\"meta\"` // unsupported\n}\n// after\ntype Config struct {\n\tMeta string `redis:\"meta\"` // raw JSON string\n}\ncfg := Config{}\nredis.Scan(&cfg)\njson.Unmarshal([]byte(cfg.Meta), &metaMap)","handlingStrategy":"validation","validationCode":"func onlySupportedFields(v interface{}) error {\n\tt := reflect.TypeOf(v)\n\tif t.Kind() != reflect.Ptr {\n\t\treturn nil\n\t}\n\tt = t.Elem()\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tk := t.Field(i).Type.Kind()\n\t\tswitch k {\n\t\tcase reflect.String, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,\n\t\t\treflect.Float32, reflect.Float64, reflect.Bool, reflect.Slice:\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"field %s has unsupported kind %s\", t.Field(i).Name, k)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := redis.Scan(&cfg); err != nil {\n\tif strings.Contains(err.Error(), \"unsupported\") {\n\t\tlog.Printf(\"struct has unsupported field type: %v\", err)\n\t}\n}","preventionTips":["Keep scanned structs to primitives, []byte, and simple slices","Unmarshal JSON/nested data manually after Scan","Document allowed field kinds on scan helper structs"],"tags":["reflection","struct-scan","unsupported-type"],"backgroundTag":"scan-unsupported-field-type","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}