{"id":"9ae7a9ba14c84ed9","repo":"go-redis/redis","slug":"redis-got-d-elements-in-slowlog-get-expected-at","errorCode":null,"errorMessage":"redis: got %d elements in slowlog get, expected at least 4","messagePattern":"redis: got (.+?) elements in slowlog get, expected at least 4","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":5702,"sourceCode":"func (cmd *SlowLogCmd) String() string {\n\tcmd.await()\n\treturn cmdString(cmd, cmd.val)\n}\n\nfunc (cmd *SlowLogCmd) readReply(rd *proto.Reader) error {\n\tn, err := rd.ReadArrayLen()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcmd.val = make([]SlowLog, n)\n\n\tfor i := 0; i < len(cmd.val); i++ {\n\t\tnn, err := rd.ReadArrayLen()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif nn < 4 {\n\t\t\treturn fmt.Errorf(\"redis: got %d elements in slowlog get, expected at least 4\", nn)\n\t\t}\n\n\t\tif cmd.val[i].ID, err = rd.ReadInt(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcreatedAt, err := rd.ReadInt()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmd.val[i].Time = time.Unix(createdAt, 0)\n\n\t\tcosts, err := rd.ReadInt()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmd.val[i].Duration = time.Duration(costs) * time.Microsecond\n","sourceCodeStart":5684,"sourceCodeEnd":5720,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L5684-L5720","documentation":"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.","triggerScenarios":"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.","commonSituations":"Redis-compatible service with a different SLOWLOG shape; transient corruption; pointing at a proxy that rewrites replies.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"entries, err := client.SlowLogGet(ctx, 128).Result()\nif err != nil {\n    // slowlog is observability-only; degrade gracefully\n    entries = nil\n}","preventionTips":["Confirm SLOWLOG GET output shape with redis-cli.","Remove RESP-rewriting proxies; treat slowlog collection as non-critical."],"tags":["slowlog","resp-parsing","server-compat","observability"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}