{"id":"01d100e86cb6c845","repo":"go-redis/redis","slug":"redis-got-d-elements-in-the-vsim-array-wanted-a-01d100","errorCode":null,"errorMessage":"redis: got %d elements in the VSIM array, wanted a multiple of 3","messagePattern":"redis: got (.+?) elements in the VSIM array, wanted a multiple of 3","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":8912,"sourceCode":"\t\t\tscore, err := rd.ReadFloat()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tattrib, err := readVectorAttribStringOrNil(rd)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcmd.val[i] = VectorScoreAttrib{Name: name, Score: score, Attribs: attrib}\n\t\t}\n\t\treturn nil\n\t}\n\n\tn, err := rd.ReadArrayLen()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif n%3 != 0 {\n\t\treturn fmt.Errorf(\"redis: got %d elements in the VSIM array, wanted a multiple of 3\", n)\n\t}\n\tcmd.val = make([]VectorScoreAttrib, n/3)\n\tfor i := range cmd.val {\n\t\tname, err := rd.ReadString()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tscore, err := rd.ReadFloat()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tattrib, err := readVectorAttribStringOrNil(rd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmd.val[i] = VectorScoreAttrib{Name: name, Score: score, Attribs: attrib}\n\t}\n\treturn nil","sourceCodeStart":8894,"sourceCodeEnd":8930,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L8894-L8930","documentation":"Returned by VectorScoreAttribSliceCmd.readReply (command.go:8912) when parsing a RESP2 reply from VSimWithArgsWithScoresWithAttribs (VSIM ... WITHSCORES WITHATTRIBS). The flat array must contain [name, score, attribute] triples; a length not divisible by 3 breaks parsing. RESP3 returns structured maps and avoids this path.","triggerScenarios":"Calling VSimWithArgsWithScoresWithAttribs with RESP2 (default) where the returned flat array length is not a multiple of 3.","commonSituations":"RESP2 protocol with an incompatible VectorSet module; server format change between minor versions; proxy mangling the array.","solutions":["Use RESP3 (Protocol: 3) for structured map replies that avoid flat-array triple parsing","Upgrade Redis and VectorSet module to a compatible version","Confirm the server supports WITHSCORES and WITHATTRIBS simultaneously"],"exampleFix":"// before\nrdb := redis.NewClient(&redis.Options{Addr: \":6379\"})\n\n// after\nrdb := redis.NewClient(&redis.Options{Addr: \":6379\", Protocol: 3})","handlingStrategy":"validation","validationCode":"opts := &redis.Options{Addr: \":6379\", Protocol: 3}\nrdb := redis.NewClient(opts)","typeGuard":null,"tryCatchPattern":"res, err := rdb.VSimWithArgsWithScoresWithAttribs(ctx, key, vec, args).Result()\nif err != nil && strings.Contains(err.Error(), \"wanted a multiple of 3\") {\n    log.Error(\"VSIM WITHSCORES WITHATTRIBS RESP2 mismatch; use Protocol:3\")\n}","preventionTips":["Use RESP3 for combined WITHSCORES WITHATTRIBS queries","Keep server and client VectorSet versions aligned"],"tags":["vectorset","vsim","withscores","withattribs","resp2","parsing"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}