{"id":"bdd00c36e2ce1c25","repo":"go-redis/redis","slug":"redis-got-d-elements-in-xautoclaimjustid-reply","errorCode":null,"errorMessage":"redis: got %d elements in XAutoClaimJustID reply, wanted 2/3","messagePattern":"redis: got (.+?) elements in XAutoClaimJustID reply, wanted 2/3","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":3448,"sourceCode":"}\n\nfunc (cmd *XAutoClaimJustIDCmd) String() string {\n\tcmd.await()\n\treturn cmdString(cmd, cmd.val)\n}\n\nfunc (cmd *XAutoClaimJustIDCmd) readReply(rd *proto.Reader) error {\n\tn, err := rd.ReadArrayLen()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch n {\n\tcase 2, // Redis 6\n\t\t3: // Redis 7:\n\t\t// ok\n\tdefault:\n\t\treturn fmt.Errorf(\"redis: got %d elements in XAutoClaimJustID reply, wanted 2/3\", n)\n\t}\n\n\tcmd.start, err = rd.ReadString()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnn, err := rd.ReadArrayLen()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.val = make([]string, nn)\n\tfor i := 0; i < nn; i++ {\n\t\tcmd.val[i], err = rd.ReadString()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":3430,"sourceCodeEnd":3466,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L3430-L3466","documentation":"Returned by XAutoClaimJustIDCmd.readReply (command.go:3448). The JUSTID variant of XAUTOCLAIM returns a top-level array of length 2 (Redis 6: cursor + IDs) or 3 (Redis 7: cursor + IDs + deleted-IDs, the last of which is discarded). Any other length yields this error to keep the parser aligned.","triggerScenarios":"Calling XAutoClaimJustID against a Redis version that returns a different top-level reply shape; a proxy mangling the array; a fork build with altered XAUTOCLAIM JUSTID semantics.","commonSituations":"Client/server skew across the Redis 6→7 boundary; experimental Redis branch; RESP-mangling proxy.","solutions":["Pin a Redis 6.x or 7.x server (both produce valid 2/3 shapes for the JUSTID variant).","If the shape is intentionally different on your build, use Do() and decode the raw reply yourself.","On this error, treat the connection as poisoned and let the pool reclaim it."],"exampleFix":"// before\nids, start, err := rdb.XAutoClaimJustID(ctx, a).Result() // odd length → error\n\n// after — fall back to full XAutoClaim and extract IDs client-side if needed\nmsgs, start, err := rdb.XAutoClaim(ctx, a).Result()\nids := make([]string, 0, len(msgs))\nfor _, m := range msgs { ids = append(ids, m.ID) }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"ids, start, err := rdb.XAutoClaimJustID(ctx, a).Result()\nif err != nil && strings.Contains(err.Error(), \"XAutoClaimJustID reply, wanted 2/3\") {\n    // unexpected shape — fall back to full XAutoClaim and extract IDs\n}","preventionTips":["Pin Redis 6.x or 7.x for the standard JUSTID shape.","Fall back to XAutoClaim and extract IDs client-side if shape differs.","Treat the connection as poisoned after this error."],"tags":["command","reply-parsing","streams","xautoclaim","protocol-mismatch"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}