Repository navigation
Commit e5d7598
authored
fix: keep vector fields in from_existing on RESP2 unified FT.INFO replies (#742)
Fixes #712
## Problem
With redis-py 8 on a RESP2 connection created with
`legacy_responses=False`, `FT.INFO` puts vector params into the field's
`flags` list:
```python
{'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_attrs` skipped `flags` entirely. It
found no `dims` and returned `None`, and `convert_index_info_to_schema`
then dropped the field with a bare `continue`. As a result,
`SearchIndex.from_existing()` + `create()` silently rebuilt the index
without its vector fields.
## Changes
1. The dict branch of `parse_vector_attrs` now unpacks key/value pairs
from `flags`. It skips valueless modifiers such as `INDEXMISSING`; I
checked on Redis 8.4 that `INDEXMISSING` is appended as a bare token
after the pairs. Top-level keys still take precedence, so RESP3 replies
(params at top level, empty `flags`) behave as before.
2. When a vector field is skipped, a warning now names the field and the
index, so the skip is no longer silent.
## Testing
- Reproduced against `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_existing` returned `['cat', 'text']` for `protocol=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.
- New unit tests in `tests/unit/test_convert_index_info.py`: `flags`
unpacking with a trailing `INDEXMISSING`, and the skip warning. Both
fail on `main` and pass here.
- `make format` and `make check-types` pass. Running `tests/unit`
(excluding `test_mcp`) plus `tests/integration/test_connection.py` gives
the same result as on `main`: the pre-existing `test_repr` failures and
`google_genai` optional-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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes index schema recovery used by `from_existing()` and recreate
flows; incorrect parsing could still drop or mis-specify vector fields,
though behavior is narrowed with tests and explicit warnings.
>
> **Overview**
> Fixes **silent loss of vector fields** when introspecting indexes with
**redis-py 8** on **RESP2** and `legacy_responses=False`, where
`FT.INFO` puts vector settings in the field's `flags` list instead of
top-level keys.
>
> `parse_vector_attrs` now walks `flags` as known key/value pairs (via
`_VECTOR_PARAM_KEYS`), skips valueless modifiers like `INDEXMISSING`,
and tolerates unknown bare tokens without mis-pairing later params.
**Dim** parsing no longer raises on bad values; unparseable vector
fields are **skipped with a warning** naming the field and index.
Integration coverage adds `protocol=2, legacy_responses=False`; unit
tests cover HNSW recovery, unknown tokens, and skip/warn paths.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
d4d7a2e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 6cb34e2 commit e5d7598
4 files changed
Lines changed: 196 additions & 4 deletions
File tree
- redisvl/redis
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
321 | 349 | | |
322 | 350 | | |
323 | 351 | | |
| |||
373 | 401 | | |
374 | 402 | | |
375 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
376 | 416 | | |
377 | 417 | | |
378 | 418 | | |
| |||
408 | 448 | | |
409 | 449 | | |
410 | 450 | | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
415 | 463 | | |
416 | 464 | | |
417 | 465 | | |
| |||
604 | 652 | | |
605 | 653 | | |
606 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
607 | 663 | | |
608 | 664 | | |
609 | 665 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
550 | 558 | | |
551 | 559 | | |
552 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
613 | 621 | | |
614 | 622 | | |
615 | 623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
0 commit comments