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

  1. Inspect raw SLOWLOG GET output and confirm every entry's command-arg array is non-empty.
  2. Eliminate proxies/intermediaries that may rewrite the reply.
  3. Retry on a fresh connection if the failure is sporadic.
  4. 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

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


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/e3b06f8cadfea82b.json. Report an issue: GitHub.