Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉 適合新手
#45 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@hugohills-regnosys 已經在處理了。

開始於 2026年10月14日。

  • #46 來自 @hugohills-regnosys —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

兩處有問題的呼叫分別位於 src/rune/runtime/base_data_class.py 的第 110 行,即呼叫 serializer(self, info) 的地方,以及 src/rune/runtime/metadata.py 的第 692 行,即呼叫 handler(obj.enum_instance, info) 的地方。請使用 issue 中的程式片段在 pydantic 2.14.1 上重現問題,然後修改這兩處呼叫,使 handler 只接收值。完成的標準是:該程式片段能印出預期的 JSON,且倉庫測試套件中失敗的 15 個測試全部通過。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
0
分支
4
平均合併
8 小時 25 分鐘
30 天內合併 PR
3

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

finos/rune-python-runtime 的其他 Issue

查看 finos/rune-python-runtime 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。