{"record":{"id":"fb242ec27cdb3bfe","repo":"redis/go-redis","slug":"redis-got-d-elements-in-the-vlinks-array-wanted","errorCode":null,"errorMessage":"redis: got %d elements in the VLINKS array, wanted a multiple of 2","messagePattern":"redis: got (.+?) elements in the VLINKS array, wanted a multiple of 2","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":8705,"sourceCode":"\t\t\t\tname, err := rd.ReadString()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tscore, err := rd.ReadFloat()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tcmd.val[i][j] = VectorScore{Name: name, Score: score}\n\t\t\t}\n\t\t} else {\n\t\t\t// RESP2 format: each level is an array of [element, score, element, score, ...] pairs\n\t\t\tinnerLen, err := rd.ReadArrayLen()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif innerLen%2 != 0 {\n\t\t\t\treturn fmt.Errorf(\"redis: got %d elements in the VLINKS array, wanted a multiple of 2\", innerLen)\n\t\t\t}\n\n\t\t\tcmd.val[i] = make([]VectorScore, innerLen/2)\n\t\t\tfor j := 0; j < innerLen; j += 2 {\n\t\t\t\tname, err := rd.ReadString()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tscore, err := rd.ReadFloat()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tcmd.val[i][j/2] = VectorScore{Name: name, Score: score}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil","sourceCodeStart":8687,"sourceCodeEnd":8723,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/command.go#L8687-L8723","documentation":"VLINKS returns, for each element, a nested array of neighbor name/score pairs. Each inner array must have an even length; an odd innerLen means the server's nested reply is malformed relative to what the client expects, so parsing aborts.","triggerScenarios":"Calling VLinks() on a vector set when one of the nested neighbor arrays has an odd number of elements at command.go:~8705.","commonSituations":"Server/client version skew on the VLINKS reply format; a server bug or proxy rewriting the nested arrays; testing against pre-GA vector-set builds.","solutions":["Upgrade both go-redis and the Redis server to current versions so VLINKS shapes match.","Run the same VLINKS command via redis-cli to inspect the raw nested arrays.","Ensure no proxy/middleware rewrites RESP arrays between client and server.","If reproducible on latest versions, file an issue with the raw reply."],"exampleFix":"// before: VLINKS inner array with 3 elements\nlinks, err := rdb.VLinks(ctx, \"pts\", \"elem\", 3)\n// redis: got 3 elements in the VLINKS array, wanted a multiple of 2\n\n// after: verify server/client versions are in sync\n// go get github.com/redis/go-redis/v9@latest\nlinks, err := rdb.VLinks(ctx, \"pts\", \"elem\", 3)","handlingStrategy":"try-catch","validationCode":"raw, _ := rdb.Do(ctx, \"VLINKS\", \"pts\", \"elem\", 3).Result()\n_ = raw // confirm each nested array has even length","typeGuard":null,"tryCatchPattern":"cmd := rdb.VLinks(ctx, \"pts\", \"elem\", 3)\nif err := cmd.Err(); err != nil {\n    if strings.Contains(err.Error(), \"VLINKS array\") {\n        // fall back to raw Do() parsing\n    }\n    return err\n}","preventionTips":["Keep server and client on compatible vector-set versions","Bypass proxies that might rewrite nested arrays","Use RESP3 for structured replies","Verify against redis-cli before coding around the error"],"tags":["redis","vectorset","vlinks","reply-parsing"],"backgroundTag":"unexpected-reply-shape","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}