redis/go-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
VSIM replies parsed into VectorScoreAttrib values contain name/score/attribute triples, so the array length must be a multiple of 3. Any other count means the reply shape does not match the requested options and parsing fails immediately.
Source
Thrown at command.go:8923
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 c5cad058c7)
Solutions
- Confirm the server supports attributes in VSIM replies and is not silently dropping them (redis-cli VSIM ... WITHSCORES WITHATTRIBS).
- Use RESP3 (Protocol: 3) so the reply structure is explicit.
- Upgrade go-redis and the Redis server to matching current versions.
- If only scores are needed, switch to the score-only variant so a 2-field reply parses correctly.
Example fix
// before: server drops attribs -> 2 fields per element vs expected 3 res, err := rdb.VSimWithScoresAttrib(ctx, "pts", vector) // redis: got 6 elements in the VSIM array, wanted a multiple of 3 // after: match the parser to the actual reply shape res, err := rdb.VSimWithScores(ctx, "pts", vector)
Defensive patterns
Strategy: try-catch
Validate before calling
raw, _ := rdb.Do(ctx, "VSIM", "pts", vec, "WITHSCORES", "WITHATTRIBS").Result() _ = raw // confirm 3 fields per element in the reply
Try / catch
cmd := rdb.VSimWithScoresAttrib(ctx, "pts", vec)
if err := cmd.Err(); err != nil {
if strings.Contains(err.Error(), "wanted a multiple of 3") {
// degrade to VSimWithScores (2 fields) or raw parsing
}
return err
} Prevention
- Confirm the server actually returns attributes for VSIM
- Match the parser variant to the requested WITH* flags
- Use RESP3 to make reply arity explicit
- Version-gate vector-set usage in CI against REDIS_VERSION
When it happens
Trigger: Calling VSIM with both WITHSCORES and WITHATTRIBS (the tri-field parser at command.go:~8923) and receiving an array whose length is not divisible by 3.
Common situations: Server returning fewer fields per element (e.g. attribs dropped for large attributes) causing arity mismatch; version skew between client expectations and server vector-set implementation; proxies altering the reply.
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
- redis: function stats unexpected running_script key %s
AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01).
Data as JSON: /api/errors/9ab4dee9d2fe53f5.
Report an issue: GitHub.