You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VADD with a single-element vector builds a malformed command (missing VALUES count)Β #3802
vadd builds an invalid command when the vector has exactly one dimension. Redis rejects it with ERR wrong number of arguments.
The cause is in RedisVectorSetCommandBuilder#vadd:
if (vectors.length > 1) {
args.add(CommandKeyword.VALUES);
args.add(vectors.length);
Arrays.stream(vectors).map(Object::toString).forEach(args::add);
} else {
args.add(vectors[0]); // VALUES and the count are skipped
}
The single-element branch skips VALUES and the count, so Lettuce sends VADD key 0.1 element instead of VADD key VALUES 1 0.1 element.
Verified against Redis 8.8.0:
# what Lettuce currently sends for a 1-D vector
> VADD vstest:lettuce 0.1 element1
(error) ERR wrong number of arguments for 'VADD' command
# with the VALUES count
> VADD vstest:correct VALUES 1 0.1 element1
(integer) 1
Input Code
RedisCommands<String, String> redis = ...;
redis.vadd("vector:set", "element1", 0.1);
// RedisCommandExecutionException: ERR wrong number of arguments for 'VADD' command
Expected behavior/code
vadd should emit the VALUES clause for a single-element vector too, so it's added like any other.
Environment
Lettuce version(s): current main (7.7.0-SNAPSHOT)
Redis version: 8.8.0 (any version with Vector Sets)
Possible Solution
Drop the special case and always write the VALUES clause:
The unit test RedisVectorSetCommandBuilderUnitTests#shouldCorrectlyConstructVaddWithOneVector asserts the malformed form (VADD vector:set 0.1 element1), so it locks in the bug and needs updating.
Every vadd integration test uses two or more elements, so the single-element path isn't covered.
Activity
a-TODO-rov commentedon Jun 26, 2026
Hey @njm1250
Thanks for the report.
Bug is confirmed and i will be glad to review your PR with the fix if you want to provide one.
Fix VADD command for single-element vectors (#3802) (#3806)
Fix VADD command for single-element vectors (#3802) (#3806)