{"id":"d86430a366989074","repo":"go-redis/redis","slug":"redis-scan-non-pointer-t","errorCode":null,"errorMessage":"redis.Scan(non-pointer %T)","messagePattern":"redis\\.Scan\\(non-pointer %T\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hscan/hscan.go","lineNumber":60,"sourceCode":"\t\treflect.Ptr:           decodeUnsupported,\n\t\treflect.Slice:         decodeSlice,\n\t\treflect.String:        decodeString,\n\t\treflect.Struct:        decodeUnsupported,\n\t\treflect.UnsafePointer: decodeUnsupported,\n\t}\n\n\t// Global map of struct field specs that is populated once for every new\n\t// struct type that is scanned. This caches the field types and the corresponding\n\t// decoder functions to avoid iterating through struct fields on subsequent scans.\n\tglobalStructMap = newStructMap()\n)\n\nfunc Struct(dst interface{}) (StructValue, error) {\n\tv := reflect.ValueOf(dst)\n\n\t// The destination to scan into should be a struct pointer.\n\tif v.Kind() != reflect.Ptr || v.IsNil() {\n\t\treturn StructValue{}, fmt.Errorf(\"redis.Scan(non-pointer %T)\", dst)\n\t}\n\n\tv = v.Elem()\n\tif v.Kind() != reflect.Struct {\n\t\treturn StructValue{}, fmt.Errorf(\"redis.Scan(non-struct %T)\", dst)\n\t}\n\n\treturn StructValue{\n\t\tspec:  globalStructMap.get(v.Type()),\n\t\tvalue: v,\n\t}, nil\n}\n\n// Scan scans the results from a key-value Redis map result set to a destination struct.\n// The Redis keys are matched to the struct's field with the `redis` tag.\nfunc Scan(dst interface{}, keys []interface{}, vals []interface{}) error {\n\tif len(keys) != len(vals) {\n\t\treturn errors.New(\"args should have the same number of keys and vals\")","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/hscan/hscan.go#L42-L78","documentation":"Error \"redis.Scan(non-pointer %T)\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/hscan/hscan.go:60 when the library encounters an invalid state.","commonSituations":"Wrap Scan in a helper taking interface{} and reflect-check pointer-ness at the boundary.","solutions":["Pass a pointer to the destination struct to Scan (e.g. cmd.Scan(&dst))","Allocate the struct first and pass its address"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}