Serialisation fails with pydantic 2.14: wrap serialisers pass SerializationInfo as index_key
评估
调研方向
两处有问题的调用分别位于 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:
pip install rune.runtime==2.2.1 pydantic==2.14.1- 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
- 派生
- 3
- 平均合并
- 8 小时 25 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
finos/rune-python-runtime 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
finos/rune-python-runtime#43 ·
-
难度 5/5 一周以上 新手友好度 35/100
finos/rune-python-runtime#42 ·
-
难度 3/5 1-2 天 新手友好度 62/100
finos/rune-python-runtime#27 ·
-
难度 5/5 一周以上 新手友好度 25/100
finos/rune-python-runtime#16 ·
-
难度 4/5 3-5 天 新手友好度 35/100
finos/rune-python-runtime#15 · 1 条评论 ·
查看 finos/rune-python-runtime 的全部 Issue
相似的 Issue
-
vis.image() reports "Unsupported number of image channels: 224" for an HxWxC image可能已有人在做 @piyush182004 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
fossasia/visdom#1997 · 3 条评论 ·
维护者通常 6 天内回复
-
Byse new domain未关闭
难度 2/5 1-3 小时 新手友好度 62/100
Gujal00/ResolveURL#1525 ·
维护者通常 1 天内回复
-
[Bug]: LangGraph Store sync put bypasses namespace validation可能已有人在做 @ktz03 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
volcengine/OpenViking#6050 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
hummingbot/condor#283 ·
维护者通常 1 天内回复
-
curriculum documentation quality
难度 2/5 1-3 小时 新手友好度 78/100
githubnext/gh-aw-workshop#4571 ·
维护者通常 1 天内回复