Fix VSIM single-element query vector missing VALUES num prefix - #3863
Open
renechoi wants to merge 1 commit into
Open
Fix VSIM single-element query vector missing VALUES num prefix#3863renechoi wants to merge 1 commit into
renechoi wants to merge 1 commit into
Conversation
Signed-off-by: renechoi <renechoi90@gmail.com>
Collaborator
|
Hey @renechoi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
vsim,vsimWithScore, orvsimWithScoreWithAttribsis invoked with a single-element query vector (i.e.vectors.length == 1), the command currently omits the requiredVALUESkeyword and the number of elements. Instead of emittingVSIM key VALUES 1 0.1, it erroneously emitsVSIM key 0.1.This fixes the issue by removing the
if (vectors.length > 1)check, guaranteeing thatVALUES <num>is consistently emitted regardless of array length, similar to howvaddhandles it.Added corresponding tests to
RedisVectorSetCommandBuilderUnitTeststo 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
VSIMwire encoding when the query vector has only one dimension.vsim,vsimWithScore, andvsimWithScoreWithAttribspreviously skipped theVALUESkeyword and count forvectors.length == 1, sendingVSIM key 0.1instead ofVSIM key VALUES 1 0.1. Theif (vectors.length > 1)branch was removed so all three paths always emitVALUES, the length, then each component—aligned withvaddand the Redis command docs.Unit tests in
RedisVectorSetCommandBuilderUnitTestsassert 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.