go-redis/redis · error
redis: unexpected response %#v
Error message
redis: unexpected response %#v
What it means
Thrown by MapMapStringInterfaceCmd.readReply (command.go:6368) on the RESP2 branch. The reply is expected to be an array of [key, value, ...] pairs; if any top-level element is not itself an array (e.g. a string or integer), the parser cannot turn it into a map and aborts.
Source
Thrown at command.go:6368
return err
}
resultMap := map[string]interface{}{}
switch midResponse := data.(type) {
case map[interface{}]interface{}: // resp3 will return map
for k, v := range midResponse {
stringKey, ok := k.(string)
if !ok {
return fmt.Errorf("redis: invalid map key %#v", k)
}
resultMap[stringKey] = v
}
case []interface{}: // resp2 will return array of arrays
n := len(midResponse)
for i := 0; i < n; i++ {
finalArr, ok := midResponse[i].([]interface{}) // final array that we need to transform to map
if !ok {
return fmt.Errorf("redis: unexpected response %#v", data)
}
m := len(finalArr)
if m%2 != 0 { // since this should be map, keys should be even number
return fmt.Errorf("redis: unexpected response %#v", data)
}
for j := 0; j < m; j += 2 {
stringKey, ok := finalArr[j].(string) // the first one
if !ok {
return fmt.Errorf("redis: invalid map key %#v", finalArr[i])
}
resultMap[stringKey] = finalArr[j+1] // second one is value
}
}
default:
return fmt.Errorf("redis: unexpected response %#v", data)
}
View on GitHub (pinned to 36d97525cd)
Solutions
- Inspect the raw reply (`redis-cli FT.CONFIG GET <option>`) and compare against what go-redis expects (array of [k, v, ...] pairs).
- Upgrade/downgrade the RediSearch module to a version whose reply shape matches, or upgrade go-redis.
- Only query known-valid CONFIG options.
- Remove any intermediary that reshapes the reply.
Defensive patterns
Strategy: try-catch
Try / catch
v, err := client.FTConfigGet(ctx, option).Result()
if err != nil {
// confirm option exists / module loaded; degrade to empty map
v = map[string]interface{}{}
} Prevention
- Only query known FT.CONFIG options.
- Confirm module is loaded and reply shape with redis-cli.
When it happens
Trigger: client.FTConfigGet(ctx, option) over RESP2 when the reply is not the expected array-of-arrays shape — e.g. a module/server that returns a flat array, an error-like bulk string mixed in, or a proxy that reshapes the reply.
Common situations: Module version mismatch (RediSearch FT.CONFIG reply shape changed); querying an option that does not exist returns an unexpected layout; RESP-rewriting proxy.
Related errors
- redis: invalid map key %#v
- invalid term format
- invalid suggestions format
- invalid suggestion format
- invalid suggestion score format
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/163a004f5b0af077.json.
Report an issue: GitHub.