Skip to content

Fixes #808 ,fix: make CompressionType case-insensitive so schema round-trips - #809

Open
Bhavy-Ranka wants to merge 1 commit into
redis:mainfrom
Bhavy-Ranka:fix/compression-case-insensitive
Open

Bhavy-Ranka wants to merge 1 commit into
redis:mainfrom
Bhavy-Ranka:fix/compression-case-insensitive

Conversation

@Bhavy-Ranka

@Bhavy-Ranka Bhavy-Ranka commented Oct 30, 2026 •

Copy link
Copy Markdown

Motivation

IndexSchema.to_dict() serializes enum values to lowercase via model_to_dict. Because CompressionType has mixed-case values (LVQ4, LVQ4x4, LVQ4x8, LVQ8, LeanVec4x8, LeanVec8x8) and lacked case-insensitive validation, schemas exported via to_dict() or to_yaml() failed with pydantic.ValidationError when reloaded via from_dict() or from_yaml(). This also caused MigrationPlanner.merge_patch() and AsyncMigrationPlanner.create_plan_from_patch() to fail for any index containing a compressed SVS-VAMANA vector field (#808).

Changes

Case-insensitive CompressionType enum lookup

Added a _missing_ classmethod to CompressionType in redisvl/schema/fields.py. It matches string inputs case-insensitively against member values, allowing lowercase values like "lvq8" or "leanvec4x8" emitted by to_dict() to resolve to their canonical members (e.g. CompressionType.LVQ8) while falling back to None for invalid values so ValueError / ValidationError is raised as expected.

Migration wizard cleanup

Replaced the manual uppercase normalization mapping dictionary in redisvl/migration/wizard.py with direct CompressionType(compression_input).value lookup and imported CompressionType.

Regression and unit tests

  • tests/unit/test_schema.py: Added test_svs_vamana_compression_yaml_round_trip parametrized across all members of CompressionType to ensure clean YAML round-tripping.
  • tests/unit/test_migration_planner.py: Added test_merge_patch_preserves_svs_vamana_compression verifying merge_patch() does not fail and preserves compression attributes.
  • tests/unit/test_async_migration_planner.py: Added test_async_planner_merge_patch_preserves_svs_vamana_compression verifying async schema patch planning preserves compression.
  • tests/unit/test_fields.py: Added tests covering exact-case input, case-insensitive lowercase input, validation errors on unknown values, and canonical uppercase argument generation in as_redis_field() / redis_args().

Release Notes

Allow case-insensitive vector compression type values in SVS-VAMANA index schemas, ensuring schemas exported to dictionaries or YAML round-trip cleanly without validation errors.

Reviewer Brief

Start here: redisvl/schema/fields.py, CompressionType._missing_. It resolves string inputs case-insensitively, enabling lower-cased enum strings emitted by model_to_dict() to map back to canonical enum members.

Where it could fail

  • redisvl/schema/fields.py:105: Ensure non-matching strings fall through to return None so standard Enum ValueError (and downstream Pydantic ValidationError) is raised for invalid options.
  • redisvl/migration/wizard.py:832: Ensure empty inputs bypass CompressionType parsing and leave compression unconfigured.

Not verified: Live Redis instances or Docker testcontainers (tests/unit run with --noconftest).

Beyond CI: Confirmed regression tests 1, 2, 3, 5, and 7 fail on main before CompressionType._missing_ is added, and pass with this change.

Reviewed 0302739 · Antigravity (Gemini 3.8 Flash) · lenses: correctness, tests, design

(AI assistance has been taken in solving this)


Note

Low Risk
Narrow enum parsing and migration-wizard input change; invalid compression still fails validation, and Redis index behavior is unchanged for already-valid schemas.

Overview
Fixes schema reload and migration failures when SVS-VAMANA compression values are not exact-case (e.g. after to_dict() / YAML export).

CompressionType now resolves string inputs case-insensitively via _missing_, mapping values like lvq8 to canonical members while still rejecting unknown strings with validation errors. Migration wizard compression prompts use that enum instead of a hand-maintained uppercase map, with a user-facing message on invalid input.

Regression tests cover YAML round-trip for every compression member, canonical FT.CREATE args from lowercase input, and sync/async merge patch flows that keep compression when adding unrelated fields.

Reviewed by Cursor Bugbot for commit 0302739. Bugbot is set up for automated code reviews on this repo. Configure here.

@Bhavy-Ranka

Copy link
Copy Markdown
Author

@claude @joshrotenberg @bsbodden @abrookins

This branch has not been deployed

No deployments
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.

1 participant