Repository navigation
Fixes #808 ,fix: make CompressionType case-insensitive so schema round-trips - #809
Open
Bhavy-Ranka wants to merge 1 commit into
Open
Bhavy-Ranka wants to merge 1 commit into
Bhavy-Ranka wants to merge 1 commit into
Conversation
Author
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.
Motivation
IndexSchema.to_dict()serializes enum values to lowercase viamodel_to_dict. BecauseCompressionTypehas mixed-case values (LVQ4,LVQ4x4,LVQ4x8,LVQ8,LeanVec4x8,LeanVec8x8) and lacked case-insensitive validation, schemas exported viato_dict()orto_yaml()failed withpydantic.ValidationErrorwhen reloaded viafrom_dict()orfrom_yaml(). This also causedMigrationPlanner.merge_patch()andAsyncMigrationPlanner.create_plan_from_patch()to fail for any index containing a compressed SVS-VAMANA vector field (#808).Changes
Case-insensitive
CompressionTypeenum lookupAdded a
_missing_classmethod toCompressionTypeinredisvl/schema/fields.py. It matches string inputs case-insensitively against member values, allowing lowercase values like"lvq8"or"leanvec4x8"emitted byto_dict()to resolve to their canonical members (e.g.CompressionType.LVQ8) while falling back toNonefor invalid values soValueError/ValidationErroris raised as expected.Migration wizard cleanup
Replaced the manual uppercase normalization mapping dictionary in
redisvl/migration/wizard.pywith directCompressionType(compression_input).valuelookup and importedCompressionType.Regression and unit tests
tests/unit/test_schema.py: Addedtest_svs_vamana_compression_yaml_round_tripparametrized across all members ofCompressionTypeto ensure clean YAML round-tripping.tests/unit/test_migration_planner.py: Addedtest_merge_patch_preserves_svs_vamana_compressionverifyingmerge_patch()does not fail and preserves compression attributes.tests/unit/test_async_migration_planner.py: Addedtest_async_planner_merge_patch_preserves_svs_vamana_compressionverifying 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 inas_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 bymodel_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 returnNoneso standard EnumValueError(and downstream PydanticValidationError) is raised for invalid options.redisvl/migration/wizard.py:832: Ensure empty inputs bypassCompressionTypeparsing and leave compression unconfigured.Not verified: Live Redis instances or Docker testcontainers (
tests/unitrun with--noconftest).Beyond CI: Confirmed regression tests 1, 2, 3, 5, and 7 fail on
mainbeforeCompressionType._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).CompressionTypenow resolves string inputs case-insensitively via_missing_, mapping values likelvq8to 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.