{"id":"64a64632150181ff","repo":"go-redis/redis","slug":"redis-the-length-of-the-array-must-be-a-multiple","errorCode":null,"errorMessage":"redis: the length of the array must be a multiple of 2, got: %d","messagePattern":"redis: the length of the array must be a multiple of 2, got: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/proto/reader.go","lineNumber":766,"sourceCode":"// If responding to the array type (RespArray/RespSet/RespPush),\n// it must be a multiple of 2 and return n/2.\n// Other types will return an error.\nfunc (r *Reader) ReadMapLen() (int, error) {\n\tline, err := r.ReadLine()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tswitch line[0] {\n\tcase RespMap:\n\t\treturn replyLen(line)\n\tcase RespArray, RespSet, RespPush:\n\t\t// Some commands and RESP2 protocol may respond to array types.\n\t\tn, err := replyLen(line)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tif n%2 != 0 {\n\t\t\treturn 0, fmt.Errorf(\"redis: the length of the array must be a multiple of 2, got: %d\", n)\n\t\t}\n\t\treturn n / 2, nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"redis: can't parse map reply: %.100q\", line)\n\t}\n}\n\n// DiscardNext read and discard the data represented by the next line.\nfunc (r *Reader) DiscardNext() error {\n\tline, err := r.readLine()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn r.Discard(line)\n}\n\n// Discard the data represented by line.\nfunc (r *Reader) Discard(line []byte) (err error) {","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/proto/reader.go#L748-L784","documentation":"Error \"redis: the length of the array must be a multiple of 2, got: %d\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/proto/reader.go:766 when the library encounters an invalid state.","commonSituations":"Build key/value lists from pairs so odd lengths are impossible.","solutions":["The key/value array length must be even; check the server reply or the constructed arguments","Reconnect if the stream is desynchronized"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}