{"id":"9325653dd819f68b","repo":"go-redis/redis","slug":"redis-got-d-elements-in-command-reply-wanted-6","errorCode":null,"errorMessage":"redis: got %d elements in COMMAND reply, wanted 6/7/10","messagePattern":"redis: got (.+?) elements in COMMAND reply, wanted 6/7/10","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":5389,"sourceCode":"\tconst numArgRedis7 = 10 // Also matches redis 8\n\n\tn, err := rd.ReadArrayLen()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcmd.val = make(map[string]*CommandInfo, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tnn, err := rd.ReadArrayLen()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tswitch nn {\n\t\tcase numArgRedis5, numArgRedis6, numArgRedis7:\n\t\t\t// ok\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"redis: got %d elements in COMMAND reply, wanted 6/7/10\", nn)\n\t\t}\n\n\t\tcmdInfo := &CommandInfo{}\n\t\tif cmdInfo.Name, err = rd.ReadString(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tarity, err := rd.ReadInt()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmdInfo.Arity = int8(arity)\n\n\t\tflagLen, err := rd.ReadArrayLen()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmdInfo.Flags = make([]string, flagLen)","sourceCodeStart":5371,"sourceCodeEnd":5407,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L5371-L5407","documentation":"Thrown by CommandsInfoCmd.readReply (command.go:5389). The COMMAND reply lists each command as an array; the parser only knows how to handle the three documented shapes: 6 fields (Redis 5), 7 fields (Redis 6, added 'since' was already present; really the keyset changed), and 10 fields (Redis 7/8, added acl-categories etc.). Any other count aborts to keep the RESP stream aligned.","triggerScenarios":"client.Command(ctx) (or the cluster router's COMMAND introspection) against a Redis whose COMMAND reply uses a different per-command array length — e.g. a much newer Redis that added fields the linked go-redis does not know, or a non-conformant fork.","commonSituations":"Running an older go-redis against a much newer Redis server that extended the COMMAND reply; using a Redis-compatible service whose COMMAND output diverges.","solutions":["Upgrade go-redis to a release that supports your Redis version's COMMAND reply shape.","Pin/downgrade Redis to a version compatible with your go-redis release.","Avoid calling Command() directly if you only need it for introspection; cache known command metadata instead.","Confirm with redis-cli COMMAND that each entry has 6/7/10 fields."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Gate COMMAND introspection by server version if you depend on its shape.\nv, err := serverVersion(ctx, client)\nif err != nil { return err }\nif !versionOK(v, \"7.0\") { /* only expect 6/7 fields */ }","typeGuard":null,"tryCatchPattern":"cmds, err := client.Command(ctx).Result()\nif err != nil {\n    // fall back to cached/known command metadata instead of failing the app\n    return knownCommands, err\n}","preventionTips":["Keep go-redis aligned with your Redis major version.","Don't build core logic on COMMAND output shape; treat it as best-effort introspection."],"tags":["command","introspection","resp-parsing","version-mismatch"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}