{"id":"72bec6425dffdf10","repo":"go-redis/redis","slug":"redis-scanslice-index-d-value-q-failed-w","errorCode":null,"errorMessage":"redis: ScanSlice index=%d value=%q failed: %w","messagePattern":"redis: ScanSlice index=(.+?) value=%q failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/proto/scan.go","lineNumber":146,"sourceCode":"\nfunc ScanSlice(data []string, slice interface{}) error {\n\tv := reflect.ValueOf(slice)\n\tif !v.IsValid() {\n\t\treturn fmt.Errorf(\"redis: ScanSlice(nil)\")\n\t}\n\tif v.Kind() != reflect.Ptr {\n\t\treturn fmt.Errorf(\"redis: ScanSlice(non-pointer %T)\", slice)\n\t}\n\tv = v.Elem()\n\tif v.Kind() != reflect.Slice {\n\t\treturn fmt.Errorf(\"redis: ScanSlice(non-slice %T)\", slice)\n\t}\n\n\tnext := makeSliceNextElemFunc(v)\n\tfor i, s := range data {\n\t\telem := next()\n\t\tif err := Scan([]byte(s), elem.Addr().Interface()); err != nil {\n\t\t\terr = fmt.Errorf(\"redis: ScanSlice index=%d value=%q failed: %w\", i, s, err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc makeSliceNextElemFunc(v reflect.Value) func() reflect.Value {\n\telemType := v.Type().Elem()\n\n\tif elemType.Kind() == reflect.Ptr {\n\t\telemType = elemType.Elem()\n\t\treturn func() reflect.Value {\n\t\t\tif v.Len() < v.Cap() {\n\t\t\t\tv.Set(v.Slice(0, v.Len()+1))\n\t\t\t\telem := v.Index(v.Len() - 1)\n\t\t\t\tif elem.IsNil() {\n\t\t\t\t\telem.Set(reflect.New(elemType))","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/proto/scan.go#L128-L164","documentation":"Error \"redis: ScanSlice index=%d value=%q failed: %w\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/proto/scan.go:146 when the library encounters an invalid state.","commonSituations":"Scan into strings first, then convert with error handling per element.","solutions":["Check the failing index and value in the error; the element type may not match the slice element type","Use a []string destination and convert elements explicitly"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}