go-redis/redis · error
redis: ScanSlice index=%d value=%q failed: %w
Error message
redis: ScanSlice index=%d value=%q failed: %w
What it means
Error "redis: ScanSlice index=%d value=%q failed: %w" thrown in go-redis/redis.
Source
Thrown at internal/proto/scan.go:146
func ScanSlice(data []string, slice interface{}) error {
v := reflect.ValueOf(slice)
if !v.IsValid() {
return fmt.Errorf("redis: ScanSlice(nil)")
}
if v.Kind() != reflect.Ptr {
return fmt.Errorf("redis: ScanSlice(non-pointer %T)", slice)
}
v = v.Elem()
if v.Kind() != reflect.Slice {
return fmt.Errorf("redis: ScanSlice(non-slice %T)", slice)
}
next := makeSliceNextElemFunc(v)
for i, s := range data {
elem := next()
if err := Scan([]byte(s), elem.Addr().Interface()); err != nil {
err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %w", i, s, err)
return err
}
}
return nil
}
func makeSliceNextElemFunc(v reflect.Value) func() reflect.Value {
elemType := v.Type().Elem()
if elemType.Kind() == reflect.Ptr {
elemType = elemType.Elem()
return func() reflect.Value {
if v.Len() < v.Cap() {
v.Set(v.Slice(0, v.Len()+1))
elem := v.Index(v.Len() - 1)
if elem.IsNil() {
elem.Set(reflect.New(elemType))View on GitHub (pinned to 36d97525cd)
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
When it happens
Trigger: Thrown at internal/proto/scan.go:146 when the library encounters an invalid state.
Common situations: Scan into strings first, then convert with error handling per element.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/72bec6425dffdf10.json.
Report an issue: GitHub.