go-redis/redis · error
redis: got %d elements in the VSIM array, wanted a multiple
Error message
redis: got %d elements in the VSIM array, wanted a multiple of 3
What it means
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.
Source
Thrown at command.go:8912
score, err := rd.ReadFloat()
if err != nil {
return err
}
attrib, err := readVectorAttribStringOrNil(rd)
if err != nil {
return err
}
cmd.val[i] = VectorScoreAttrib{Name: name, Score: score, Attribs: attrib}
}
return nil
}
n, err := rd.ReadArrayLen()
if err != nil {
return err
}
if n%3 != 0 {
return fmt.Errorf("redis: got %d elements in the VSIM array, wanted a multiple of 3", n)
}
cmd.val = make([]VectorScoreAttrib, n/3)
for i := range cmd.val {
name, err := rd.ReadString()
if err != nil {
return err
}
score, err := rd.ReadFloat()
if err != nil {
return err
}
attrib, err := readVectorAttribStringOrNil(rd)
if err != nil {
return err
}
cmd.val[i] = VectorScoreAttrib{Name: name, Score: score, Attribs: attrib}
}
return nilView on GitHub (pinned to 36d97525cd)
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
Example fix
// before
rdb := redis.NewClient(&redis.Options{Addr: ":6379"})
// after
rdb := redis.NewClient(&redis.Options{Addr: ":6379", Protocol: 3}) Defensive patterns
Strategy: validation
Validate before calling
opts := &redis.Options{Addr: ":6379", Protocol: 3}
rdb := redis.NewClient(opts) Try / catch
res, err := rdb.VSimWithArgsWithScoresWithAttribs(ctx, key, vec, args).Result()
if err != nil && strings.Contains(err.Error(), "wanted a multiple of 3") {
log.Error("VSIM WITHSCORES WITHATTRIBS RESP2 mismatch; use Protocol:3")
} Prevention
- Use RESP3 for combined WITHSCORES WITHATTRIBS queries
- Keep server and client VectorSet versions aligned
When it happens
Trigger: Calling VSimWithArgsWithScoresWithAttribs with RESP2 (default) where the returned flat array length is not a multiple of 3.
Common situations: RESP2 protocol with an incompatible VectorSet module; server format change between minor versions; proxy mangling the array.
Related errors
- redis: got %d elements in the VSIM array, wanted a multiple
- redis: VectorScoreSliceCmd expects even number of elements,
- redis: got %d elements in the VLINKS array, wanted a multipl
- redis: can't parse reply=%T reading string
- invalid term format
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/01d100e86cb6c845.json.
Report an issue: GitHub.