Conversation
…lies With redis-py 8, protocol=2 and legacy_responses=False, FT.INFO packs vector params into the field's flags list. parse_vector_attrs ignored flags, found no dims, and the caller dropped the field without a trace, so from_existing() + create() rebuilt the index without its vectors. Unpack key/value pairs from flags (skipping valueless modifiers such as INDEXMISSING), and log a warning when a vector field is skipped. Fixes redis#712
This branch has not been deployed
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.
Fixes #712
Problem
With redis-py 8 on a RESP2 connection created with
legacy_responses=False,FT.INFOputs vector params into the field'sflagslist:{'identifier': 'h', 'attribute': 'h', 'type': 'VECTOR', 'flags': ['algorithm', 'HNSW', 'data_type', 'FLOAT32', 'dim', 8, 'distance_metric', 'L2', 'M', 24, 'ef_construction', 300, 'INDEXMISSING']}The dict branch of
parse_vector_attrsskippedflagsentirely. It found nodimsand returnedNone, andconvert_index_info_to_schemathen dropped the field with a barecontinue. As a result,SearchIndex.from_existing()+create()silently rebuilt the index without its vector fields.Changes
parse_vector_attrsnow unpacks key/value pairs fromflags. It skips valueless modifiers such asINDEXMISSING; I checked on Redis 8.4 thatINDEXMISSINGis appended as a bare token after the pairs. Top-level keys still take precedence, so RESP3 replies (params at top level, emptyflags) behave as before.Testing
redis:8.4+ redis-py 8.1.0 with a FLAT and an HNSW (m=24,ef_construction=300) vector field. Before this change,from_existingreturned['cat', 'text']forprotocol=2, legacy_responses=False. After it, all three client configurations (protocol=2,protocol=2, legacy_responses=False,protocol=3) recover the identical schema, including the HNSW params.tests/unit/test_convert_index_info.py:flagsunpacking with a trailingINDEXMISSING, and the skip warning. Both fail onmainand pass here.make formatandmake check-typespass. Runningtests/unit(excludingtest_mcp) plustests/integration/test_connection.pygives the same result as onmain: the pre-existingtest_reprfailures andgoogle_genaioptional-dependency errors, which are unrelated to this change, plus the 2 new tests passing.AI disclosure: this change was prepared with an AI coding assistant (Claude Code). I reviewed the diff and ran the tests above.
🤖 Generated with Claude Code
Note
Medium Risk
Changes index schema reconstruction from FT.INFO for vector fields; incorrect parsing could still misrepresent indexes on recreate, but scope is limited to a known redis-py 8 RESP2 reply shape.
Overview
Fixes silent loss of vector fields when rebuilding schemas from
FT.INFOunder redis-py 8 on RESP2 withlegacy_responses=False, where vector parameters are encoded as key/value pairs inside the field'sflagslist (sometimes followed by bare modifiers likeINDEXMISSING).parse_vector_attrsnow walks thoseflagspairs when attributes arrive as a dict, skipping valueless FT.INFO modifiers via_VECTOR_VALUELESS_FLAGS, while still preferring top-level keys so RESP3-style replies are unchanged. When vector attributes still cannot be parsed,convert_index_info_to_schemalogs a warning naming the field and index instead of dropping the field quietly—restoring correct behavior forSearchIndex.from_existing()/ index recreation.Unit tests cover RESP2 unified
flagsunpacking (including HNSW params and trailingINDEXMISSING) and the new skip warning.Reviewed by Cursor Bugbot for commit 192d689. Bugbot is set up for automated code reviews on this repo. Configure here.