Skip to content

VADD with a single-element vector builds a malformed command (missing VALUES count)Β #3802

Closed

Description

@njm1250

Bug Report

Current Behavior

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:

args.add(CommandKeyword.VALUES);
args.add(vectors.length);
Arrays.stream(vectors).map(Object::toString).forEach(args::add);

Additional context

Not covered by tests:

  • 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.

If you'd like, I'm happy to open a PR.

Activity

  1. added theissue type on Jun 26, 2026
  2. a-TODO-rov commented on Jun 26, 2026

    @a-TODO-rov
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions