go-redis/redis · error
redis: function stats unexpected %s engine map length
Error message
redis: function stats unexpected %s engine map length
What it means
Thrown by FunctionStatsCmd.readEngines (command.go:7027) when each engine's value map is not exactly 2 entries (libraries_count and functions_count). The parser uses ReadFixedMapLen(2), so any other length aborts.
Source
Thrown at command.go:7027
}
func (cmd *FunctionStatsCmd) readEngines(rd *proto.Reader) ([]Engine, error) {
n, err := rd.ReadMapLen()
if err != nil {
return nil, err
}
engines := make([]Engine, 0, n)
for i := 0; i < n; i++ {
engine := Engine{}
engine.Language, err = rd.ReadString()
if err != nil {
return nil, err
}
err = rd.ReadFixedMapLen(2)
if err != nil {
return nil, fmt.Errorf("redis: function stats unexpected %s engine map length", engine.Language)
}
for i := 0; i < 2; i++ {
key, err := rd.ReadString()
if err != nil {
return nil, err
}
switch key {
case "libraries_count":
engine.LibrariesCount, err = rd.ReadInt()
case "functions_count":
engine.FunctionsCount, err = rd.ReadInt()
default:
// Unknown field: drain its value so the reader stays aligned
// with the rest of the reply.
err = rd.DiscardNext()
}
if err != nil {View on GitHub (pinned to 36d97525cd)
Solutions
- Upgrade go-redis to a release supporting the new engine-stat fields (or that drains extra fields).
- Pin Redis to a compatible version.
- Confirm with `FUNCTION STATS` what keys each engine map contains.
Defensive patterns
Strategy: validation
Validate before calling
// redis-cli FUNCTION STATS -> confirm each engine map has exactly libraries_count + functions_count.
Try / catch
stats, err := client.FunctionStats(ctx).Result()
if err != nil {
// upgrade go-redis for new engine-stat fields; degrade
stats = redis.FunctionStats{}
} Prevention
- Pin Redis to a version your go-redis supports, or upgrade go-redis first.
- Treat engine stats as best-effort.
When it happens
Trigger: client.FunctionStats(ctx) when an engine map under 'engines' has a length other than 2 — e.g. a newer Redis added a third engine-stat field, or a fork/proxy returned a different shape.
Common situations: Forward-compat drift: newer Redis adding per-engine statistics; Redis fork with a different engines shape.
Related errors
- redis: function stats unexpected key %s
- redis: function stats unexpected running_script key %s
- redis: function list unexpected key %s
- redis: got %d elements in COMMAND reply, wanted 6/7/10
- redis: unexpected key %q in CLUSTER LINKS reply
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/e100ce458f48289d.json.
Report an issue: GitHub.