go-redis/redis · error
redis: RESP3 map key must be a scalar type, got %T
Error message
redis: RESP3 map key must be a scalar type, got %T
What it means
Error "redis: RESP3 map key must be a scalar type, got %T" thrown in go-redis/redis.
Source
Thrown at internal/proto/reader.go:469
func (r *Reader) readMap(line []byte) (map[interface{}]interface{}, error) {
n, err := replyLen(line)
if err != nil {
return nil, err
}
m := make(map[interface{}]interface{}, n)
for i := 0; i < n; i++ {
k, err := r.ReadReply()
if err != nil {
return nil, err
}
// Reject unhashable keys (arrays/maps) before they are used as a map
// key, which would otherwise panic. This check must run before the
// value is read so it also guards the Nil and RedisError paths below,
// which write the key into the map and continue.
switch k.(type) {
case []interface{}, map[interface{}]interface{}:
return nil, fmt.Errorf("redis: RESP3 map key must be a scalar type, got %T", k)
}
v, err := r.ReadReply()
if err != nil {
if err == Nil {
m[k] = nil
continue
}
if err, ok := err.(RedisError); ok {
m[k] = err
continue
}
return nil, err
}
m[k] = v
}
return m, nilView on GitHub (pinned to 36d97525cd)
Solutions
- Ensure map keys in RESP3 replies are scalar (string/int/float/bool); nested aggregates as keys are unsupported
- Handle the raw reply manually if the server emits non-scalar keys
When it happens
Trigger: Thrown at internal/proto/reader.go:469 when the library encounters an invalid state.
Common situations: For commands with unusual replies, read into a raw/generic type instead of a typed map.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/6c8ff7efdcfb980c.json.
Report an issue: GitHub.