fix(python/redis): restore vector search broken by redisvl>=0.5 API change and KeyError on include_vectors=False - #14278
Open
Patrick Ribbsaeter (patrickswedish) wants to merge 4 commits into
Conversation
…ard KeyError on include_vectors=False
Two independent bugs made vector search completely unusable:
1. **process_results() API break (redisvl >= 0.5)**
`redisvl` 0.5.0 changed the third argument of `process_results()` from
`StorageType` (an enum value) to `IndexSchema` (an object). The SK
`pyproject.toml` pin `redisvl ~= 0.4` resolves via PEP 440 to
`>=0.4, <1.0`, so `uv.lock` picks up redisvl 0.15.x where the old
API no longer exists. Every call to `collection.search()` raised:
AttributeError: 'StorageType' object has no attribute 'index'
Fix: detect the redisvl API version at runtime using `inspect.signature`
and call `process_results()` with either the legacy `StorageType` enum
or the new `IndexSchema` object accordingly, with a fallback swap if
the initial detection is wrong.
2. **KeyError in RedisHashsetCollection._deserialize_store_models_to_dicts**
The deserializer unconditionally called `buffer_to_array(rec[field.name], dtype)`
for every vector field. When `include_vectors=False` (the default for
search), the vector field is absent from the result dict, producing:
KeyError: 'vector'
Fix: check `if storage_name in rec` before decoding. When the field is
absent (not returned by Redis), set the model attribute to `None` rather
than raising.
Together these two defects blocked all FT.SEARCH usage regardless of
collection type or include_vectors setting.
Fixes microsoft#13896
Patrick Ribbsaeter (patrickswedish)
requested a review
from a team
as a code owner
August 6, 2026 19:30
Author
|
Hi team! 👋 This PR fixes two independent bugs that break all Redis vector search for Python users running
Both fixes are backward-compatible — runtime API sniffing handles both old and new redisvl versions. Happy to add tests or address any review feedback! |
Copilot started reviewing on behalf of
Patrick Ribbsaeter (patrickswedish)
August 6, 2026 23:23
View session
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.
Summary
Fixes #13896.
Vector search (
FT.SEARCH) via the Python Redis connector was completely broken due to two independent bugs. Both have been fixed in this PR.Bug 1 —
process_results()API break with redisvl >= 0.5Root cause
redisvl0.5.0 changed the signature ofprocess_results():The
pyproject.tomlpinredisvl ~= 0.4resolves to>=0.4, <1.0under PEP 440, souv.locksilently picks up redisvl 0.15.x where the old API is gone. Every call tocollection.search()raised:Fix
Detect the redisvl API version at runtime via
inspect.signatureand callprocess_results()with the appropriate third argument. A fallback swap is included in case the signature inspection is ambiguous:Bug 2 —
KeyErrorinRedisHashsetCollection._deserialize_store_models_to_dictsRoot cause
The deserializer unconditionally decoded every vector field:
When
include_vectors=False(the SDK default for search), Redis does not return vector fields in the result dict, sorec[field.name]raisedKeyError: 'vector'.Fix
Guard with an existence check before decoding:
Impact
Both bugs affected every Python user using the Redis connector for vector search:
include_vectors=False(the default).The connector was written against redisvl 0.4.x; the dependency pin allows installation of redisvl 0.15.x where the API changed.
Testing