go-redis/redis · error
redis: got %d elements commands reply in slowlog get, expect
Error message
redis: got %d elements commands reply in slowlog get, expected at least 1
What it means
Thrown by SlowLogCmd.readReply (command.go:5726). Inside each SLOWLOG GET entry the fourth field is itself an array of command arguments; the parser requires at least one element (the command name). A zero-length args array is rejected because it cannot represent any command.
Source
Thrown at command.go:5726
createdAt, err := rd.ReadInt()
if err != nil {
return err
}
cmd.val[i].Time = time.Unix(createdAt, 0)
costs, err := rd.ReadInt()
if err != nil {
return err
}
cmd.val[i].Duration = time.Duration(costs) * time.Microsecond
cmdLen, err := rd.ReadArrayLen()
if err != nil {
return err
}
if cmdLen < 1 {
return fmt.Errorf("redis: got %d elements commands reply in slowlog get, expected at least 1", cmdLen)
}
cmd.val[i].Args = make([]string, cmdLen)
for f := 0; f < len(cmd.val[i].Args); f++ {
cmd.val[i].Args[f], err = rd.ReadString()
if err != nil {
return err
}
}
if nn >= 5 {
if cmd.val[i].ClientAddr, err = rd.ReadString(); err != nil {
return err
}
}
if nn >= 6 {
if cmd.val[i].ClientName, err = rd.ReadString(); err != nil {View on GitHub (pinned to 36d97525cd)
Solutions
- Inspect raw SLOWLOG GET output and confirm every entry's command-arg array is non-empty.
- Eliminate proxies/intermediaries that may rewrite the reply.
- Retry on a fresh connection if the failure is sporadic.
- Upgrade go-redis and Redis to current stable versions.
Defensive patterns
Strategy: try-catch
Try / catch
entries, err := client.SlowLogGet(ctx, 128).Result()
if err != nil {
// likely transport corruption or non-conformant server; log and continue
entries = nil
} Prevention
- Treat SLOWLOG collection as best-effort and never fail user requests on it.
- Keep transport/proxy path clean.
When it happens
Trigger: client.SlowLogGet(ctx, num) when a slowlog entry's command-args sub-array is empty — a malformed/corrupted reply or a non-conformant server.
Common situations: Corrupted RESP frame during transport; a Redis fork/proxy that emits empty command arrays; extremely rare server-side corruption.
Related errors
- redis: got %d elements in slowlog get, expected at least 4
- redis: got %d elements in latency get, expected at least 4
- redisotel: already initialized, call Shutdown() before reini
- redis: got %d elements in cluster info, expected at least 2
- got %d elements in cluster info address, expected 2, 3, or 4
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/e3b06f8cadfea82b.json.
Report an issue: GitHub.