Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Serialisation fails with pydantic 2.14: wrap serialisers pass SerializationInfo as index_key

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

@hugohills-regnosys đang làm issue này rồi.

Từ ngày 14/10/2026.

  • #46 của @hugohills-regnosys — đ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
82/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

Hai lời gọi có vấn đề nằm trong src/rune/runtime/base_data_class.py ở dòng 110, nơi gọi serializer(self, info), và trong src/rune/runtime/metadata.py ở dòng 692, nơi gọi handler(obj.enum_instance, info). Hãy tái hiện lỗi bằng đoạn mã trong issue trên pydantic 2.14.1, sau đó sửa cả hai lời gọi để handler chỉ nhận giá trị. Công việc hoàn thành khi đoạn mã in ra JSON mong đợi và 15 bài kiểm tra đang lỗi trong bộ kiểm thử của repo đều pass.

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

Mô tả

Bug Report

With pydantic 2.14, serialising any BaseDataClass fails. pyproject.toml allows any pydantic >=2.10.3, so a fresh install gets 2.14.1 and breaks.

Two wrap serialisers pass pydantic's SerializationInfo as the second positional argument of the handler they are given. That argument is index_key (def __call__(self, input_value, index_key: int | str | None = None, /)). Up to 2.13, pydantic accepted whatever was passed there; 2.14 checks its type:

  • src/rune/runtime/base_data_class.py:110: serializer(self, info)
  • src/rune/runtime/metadata.py:692: handler(obj.enum_instance, info)
Steps to Reproduce:
  1. pip install rune.runtime==2.2.1 pydantic==2.14.1
  2. Run:
    from rune.runtime.base_data_class import BaseDataClass
    
    class A(BaseDataClass):
        value: int | None = None
    
    print(A(value=1).rune_serialize())
    
Expected Result:

{"@type":"__main__","@model":"__main__","@version":"0.0.0","value":1}, which is what pydantic 2.12.5 and 2.13.4 produce.

Actual Result:
pydantic_core._pydantic_core.PydanticSerializationError: Error serializing to JSON: PydanticSerializationError: Error calling function `_serialize_refs`: TypeError: 'index_key' is expected to be an integer or a string, got 'SerializationInfo(include=None, exclude=None, context=None, mode='json', by_alias=False, exclude_unset=True, exclude_defaults=True, exclude_none=False, exclude_computed_fields=False, round_trip=False, serialize_as_any=False)'

On main with pydantic 2.14.1, 15 tests in this repo's suite fail this way.

Environment:

rune.runtime 2.2.1 and main (b0fa1cd), pydantic 2.14.1 / pydantic-core 2.50.1, Python 3.12, macOS.

Additional Context:

The fix is to call the handler with the value only. The rune-python-generator Python unit tests (features/serialization/) hit the same error, because generated packages also leave pydantic unpinned.

Ngôn ngữ chính
Python
Star
0
Fork
3
Merge trung bình
8 giờ 25 phút
Pull request đã merge (30 ngày)
3

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 finos/rune-python-runtime

Tất cả issue của finos/rune-python-runtime

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.