SVS-VAMANA `compression` does not survive `IndexSchema.to_dict()`, breaking YAML round-trips and migration planning

Đang mở Phù hợp với người mới
#808 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

@Bhavy-Ranka đang làm issue này rồi.

Từ ngày 30/10/2026.

  • #809 của @Bhavy-Ranka — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong redisvl/schema/fields.py tại CompressionType và BaseVectorFieldAttributes, sau đó đọc model_to_dict trong redisvl/utils/utils.py, đoạn này chuyển các giá trị enum thành chữ thường. Thêm tra cứu enum không phân biệt chữ hoa chữ thường, sau đó kiểm tra đường đi round-trip YAML trong IndexSchema.to_yaml()/from_yaml() và đường đi MigrationPlanner.merge_patch() được nêu trong issue. Hoàn tất nghĩa là mọi giá trị nén đều sống sót qua to_yaml() rồi from_yaml(), merge_patch() hoạt động với một trường vector đã nén hiện có, và đầu vào đúng chính xác chữ hoa chữ thường vẫn tạo ra giá trị chuẩn cho FT.CREATE.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

IndexSchema.to_dict() writes an SVS-VAMANA field's compression in lower case, but IndexSchema.from_dict() accepts only the exact-case value, so a schema with compression cannot be read back from its own output. to_yaml() followed by from_yaml() fails for every CompressionType, and MigrationPlanner.merge_patch() fails for any index that already uses compression, even when the patch does not touch the vector field.

Reproduction

Measured on main at 6a81e13b with Python 3.13.9:

from redisvl.schema import IndexSchema

schema = IndexSchema.from_dict({
    "index": {"name": "a", "prefix": "a"},
    "fields": [{
        "name": "v",
        "type": "vector",
        "attrs": {"algorithm": "svs-vamana", "dims": 8, "compression": "LVQ8"},
    }],
})

schema.to_dict()["fields"][0]["attrs"]["compression"]  # 'lvq8'

schema.to_yaml("schema.yaml")
IndexSchema.from_yaml("schema.yaml")
# ValidationError: attrs.compression
#   Input should be 'LVQ4', 'LVQ4x4', 'LVQ4x8', 'LVQ8', 'LeanVec4x8' or 'LeanVec8x8'
#   [type=enum, input_value='lvq8', input_type=str]

All six values fail the same way: LVQ4, LVQ4x4, LVQ4x8, LVQ8, LeanVec4x8 and LeanVec8x8.

The migration planner hits the same error. Adding a numeric field to an index whose vector field uses LVQ8 raises it from MigrationPlanner().merge_patch(source_schema, patch), because merge_patch rebuilds the target schema with IndexSchema.from_dict(source_schema.to_dict()). AsyncMigrationPlanner calls the same merge_patch. Post-migration validation should fail the same way, since redisvl/migration/validation.py passes target_index.schema.to_dict() to canonicalize_schema, which calls IndexSchema.from_dict() on it; that follows from the code and has not been reproduced.

Cause

model_to_dict in redisvl/utils/utils.py serialises every enum as item.value.lower(). That is harmless for algorithm, datatype and distance_metric, because BaseVectorFieldAttributes.uppercase_strings in redisvl/schema/fields.py upper-cases them on input. compression has no such validator, and its values are mixed case, so the lower-cased output no longer matches any member.

Proposed fix

Make CompressionType accept its values case-insensitively, with a _missing_ classmethod that returns the member whose value matches ignoring case. Checked in isolation with pydantic 2.13: a model field typed with such an enum accepts "lvq8" and "LeanVec4x8" and still rejects unknown values. That keeps to_dict() output in the same lower-case convention as the other vector attributes, and it also loads YAML files that to_yaml() has already written in lower case, which a fix confined to the output side would leave unreadable. The case mapping in redisvl/migration/wizard.py, which exists to turn user input into the exact member value, can then be simplified.

Acceptance

  • IndexSchema.from_yaml() loads the output of to_yaml() for every CompressionType, with a regression test that fails before the fix.
  • MigrationPlanner.merge_patch() succeeds for a source index that uses compression, with a regression test.
  • Explicit exact-case values such as "LeanVec4x8" continue to work, and FT.CREATE still sends the canonical value.
Ngôn ngữ chính
Python
Star
433
Fork
120
Merge trung bình
7 ngày 18 giờ
Pull request đã merge (30 ngày)
28

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của redis/redis-vl-python

Tất cả issue của redis/redis-vl-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.