go-redis/redis · error
redis: got %d elements in slowlog get, expected at least 4
Error message
redis: got %d elements in slowlog get, expected at least 4
What it means
Thrown by SlowLogCmd.readReply (command.go:5702). Each SLOWLOG GET entry must have at least 4 fields (id, timestamp, duration-us, command-args); the parser reads those four unconditionally, so a shorter entry would desync the stream and is rejected.
Source
Thrown at command.go:5702
func (cmd *SlowLogCmd) String() string {
cmd.await()
return cmdString(cmd, cmd.val)
}
func (cmd *SlowLogCmd) readReply(rd *proto.Reader) error {
n, err := rd.ReadArrayLen()
if err != nil {
return err
}
cmd.val = make([]SlowLog, n)
for i := 0; i < len(cmd.val); i++ {
nn, err := rd.ReadArrayLen()
if err != nil {
return err
}
if nn < 4 {
return fmt.Errorf("redis: got %d elements in slowlog get, expected at least 4", nn)
}
if cmd.val[i].ID, err = rd.ReadInt(); err != nil {
return err
}
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
View on GitHub (pinned to 36d97525cd)
Solutions
- Verify with `redis-cli SLOWLOG GET 10` that every entry has at least id/time/us/command.
- Remove RESP-rewriting proxies from the path.
- Upgrade go-redis (the parser tolerates extra trailing fields like the Redis 8.10 total-args field).
- Retry if the failure looks transient.
Defensive patterns
Strategy: try-catch
Try / catch
entries, err := client.SlowLogGet(ctx, 128).Result()
if err != nil {
// slowlog is observability-only; degrade gracefully
entries = nil
} Prevention
- Confirm SLOWLOG GET output shape with redis-cli.
- Remove RESP-rewriting proxies; treat slowlog collection as non-critical.
When it happens
Trigger: client.SlowLogGet(ctx, num) where a slowlog entry array has fewer than 4 elements: a non-conformant Redis fork, a proxy mangling the reply, or a corrupted/truncated RESP frame.
Common situations: Redis-compatible service with a different SLOWLOG shape; transient corruption; pointing at a proxy that rewrites replies.
Related errors
- redis: got %d elements commands reply in slowlog get, expect
- redis: got %d elements in latency get, expected at least 4
- redis: got %d elements in cluster info, expected at least 2
- got %d elements in cluster info address, expected 2, 3, or 4
- redis: got %d elements in GEOSEARCH reply, expected at least
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/9ae7a9ba14c84ed9.json.
Report an issue: GitHub.