{"id":"91fe7df5e550dbac","repo":"go-redis/redis","slug":"redis-got-d-elements-in-the-vsim-array-wanted-a","errorCode":null,"errorMessage":"redis: got %d elements in the VSIM array, wanted a multiple of 2","messagePattern":"redis: got (.+?) elements in the VSIM array, wanted a multiple of 2","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":8814,"sourceCode":"\t\t\tname, err := rd.ReadString()\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] = VectorAttrib{Name: name, 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%2 != 0 {\n\t\treturn fmt.Errorf(\"redis: got %d elements in the VSIM array, wanted a multiple of 2\", n)\n\t}\n\tcmd.val = make([]VectorAttrib, n/2)\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\tattrib, err := readVectorAttribStringOrNil(rd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmd.val[i] = VectorAttrib{Name: name, Attribs: attrib}\n\t}\n\treturn nil\n}\n\nfunc (cmd *VectorAttribSliceCmd) Clone() Cmder {\n\treturn &VectorAttribSliceCmd{","sourceCodeStart":8796,"sourceCodeEnd":8832,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L8796-L8832","documentation":"Returned by VectorAttribSliceCmd.readReply (command.go:8814) when parsing a RESP2 reply from VSimWithArgsWithAttribs (VSIM ... WITHATTRIBS). The flat RESP2 array must contain [name, attribute] pairs; an odd element count breaks pairing. RESP3 returns a map and never reaches this check.","triggerScenarios":"Calling VSimWithArgsWithAttribs with RESP2 (default) where the returned flat array length is not a multiple of 2.","commonSituations":"RESP2 protocol with an incompatible VectorSet module version; proxy corrupting the array structure; server-side format change.","solutions":["Use RESP3 (Protocol: 3) so VSIM returns a structured map reply","Upgrade the Redis VectorSet module to a version matching this go-redis","Verify WITHATTRIBS is supported by the server"],"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.VSimWithArgsWithAttribs(ctx, key, vec, args).Result()\nif err != nil && strings.Contains(err.Error(), \"wanted a multiple of 2\") {\n    log.Error(\"VSIM WITHATTRIBS RESP2 format mismatch; use Protocol:3\")\n}","preventionTips":["Use RESP3 for VSIM WITHATTRIBS commands","Match the server VectorSet version with go-redis"],"tags":["vectorset","vsim","withattribs","resp2","parsing"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}