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
派生
3
平均合并
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 摘要。