Skip to content

Fix VSIM single-element query vector missing VALUES num prefix - #3863

Open
renechoi wants to merge 2 commits into
redis:mainfrom
renechoi:fix-vsim-single-element
Open

Fix VSIM single-element query vector missing VALUES num prefix#3863
renechoi wants to merge 2 commits into
redis:mainfrom
renechoi:fix-vsim-single-element

Conversation

@renechoi

@renechoi renechoi commented Jul 24, 2026

Copy link
Copy Markdown

Description

When vsim, vsimWithScore, or vsimWithScoreWithAttribs is invoked with a single-element query vector (i.e. vectors.length == 1), the command currently omits the required VALUES keyword and the number of elements. Instead of emitting VSIM key VALUES 1 0.1, it erroneously emits VSIM key 0.1.

This fixes the issue by removing the if (vectors.length > 1) check, guaranteeing that VALUES <num> is consistently emitted regardless of array length, similar to how vadd handles it.

Added corresponding tests to RedisVectorSetCommandBuilderUnitTests to verify the fix.


Note

Low Risk
Localized protocol-encoding bug fix in vector-set command builders with new unit tests; no auth, persistence, or broad API changes.

Overview
Fixes incorrect VSIM wire encoding when the query vector is a single-element Double[]. Those code paths used to send only the lone float (e.g. VSIM key 0.1) instead of the required VALUES count and components (e.g. VSIM key VALUES 1 0.1).

RedisVectorSetCommandBuilder now always emits VALUES, the length, and each component for vector-based vsim, vsimWithScore, and vsimWithScoreWithAttribs, matching vadd and multi-element VSIM behavior. Unit tests assert the encoded RESP for one-dimensional queries across all three variants.

Reviewed by Cursor Bugbot for commit d98a0eb. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: renechoi <renechoi90@gmail.com>
@a-TODO-rov

Copy link
Copy Markdown
Collaborator

Hey @renechoi
Thanks for contributing.
Could you please open an issue first for community visibility. Otherwise fix seems correct.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants