Skip to content

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

Open
renechoi wants to merge 1 commit into
redis:mainfrom
renechoi:fix-vsim-single-element
Open

Fix VSIM single-element query vector missing VALUES num prefix#3863
renechoi wants to merge 1 commit 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

Medium Risk
Changes the on-the-wire protocol for single-vector VSIM calls (previously invalid); multi-vector behavior is unchanged and callers on the broken path should see fixed server compatibility rather than new breakage.

Overview
Fixes malformed Redis VSIM wire encoding when the query vector has only one dimension.

vsim, vsimWithScore, and vsimWithScoreWithAttribs previously skipped the VALUES keyword and count for vectors.length == 1, sending VSIM key 0.1 instead of VSIM key VALUES 1 0.1. The if (vectors.length > 1) branch was removed so all three paths always emit VALUES, the length, then each component—aligned with vadd and the Redis command docs.

Unit tests in RedisVectorSetCommandBuilderUnitTests assert the encoded RESP for single-vector calls on each variant.

Reviewed by Cursor Bugbot for commit 4c78c57. 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