{"id":"c7de856c82607917","repo":"go-redis/redis","slug":"redis-got-d-elements-in-xautoclaim-reply-wanted","errorCode":null,"errorMessage":"redis: got %d elements in XAutoClaim reply, wanted 2/3","messagePattern":"redis: got (.+?) elements in XAutoClaim reply, wanted 2/3","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":3237,"sourceCode":"}\n\nfunc (cmd *XAutoClaimCmd) String() string {\n\tcmd.await()\n\treturn cmdString(cmd, cmd.val)\n}\n\nfunc (cmd *XAutoClaimCmd) 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 XAutoClaim 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\tcmd.val, err = readXMessageSlice(rd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif n >= 3 {\n\t\treturn rd.DiscardNext()\n\t}\n\n\treturn nil\n}","sourceCodeStart":3219,"sourceCodeEnd":3255,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L3219-L3255","documentation":"Returned by XAutoClaimCmd.readReply (command.go:3237). XAUTOCLAIM's top-level reply is an array of length 2 (Redis 6: cursor + messages) or 3 (Redis 7: cursor + messages + deleted-IDs). Any other length yields this error so the parser does not desynchronize the connection.","triggerScenarios":"Calling XAutoClaim against a Redis version whose top-level reply shape differs (future major version adding a fourth element); a RESP proxy mangling the array length; a fork build with modified XAUTOCLAIM semantics.","commonSituations":"Client/server version skew across the Redis 6→7 boundary (deleted-IDs element); a proxy that rewrites array framing; an experimental Redis branch.","solutions":["Use a Redis version compatible with the client (Redis 6 or 7 for the standard 2/3 shape).","If you need the deleted-ID list on Redis 7, prefer XAutoClaimWithDeleted (which actually parses element 3).","On this error the connection is poisoned; let it be reclaimed by the pool."],"exampleFix":"// before\nmsgs, start, err := rdb.XAutoClaim(ctx, a).Result() // on a future/odd Redis build → error\n\n// after — use the version-appropriate accessor, pin server version\nmsgs, start, deleted, err := rdb.XAutoClaimWithDeleted(ctx, a).Result()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"msgs, start, err := rdb.XAutoClaim(ctx, a).Result()\nif err != nil && strings.Contains(err.Error(), \"XAutoClaim reply, wanted 2/3\") {\n    // unexpected top-level shape — pin Redis version; if you need deleted IDs, use WithDeleted\n}","preventionTips":["Pin Redis 6.x or 7.x for the standard XAUTOCLAIM shape.","Use XAutoClaimWithDeleted when you need the deleted-IDs element.","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}