BasicTypeMetaDataMixin.deserialize calls _init_meta on None.
还没有人认领这个 Issue。
评估
调研方向
阅读 metadata.py 并检查 BasicTypeMetaDataMixin.deserialize,尤其是调用 _init_meta 前它如何处理 obj。先用提供的示例 DateWithMeta.deserialize(None, ...) 重现故障。完成标准是将 None 传给处理器,并且可选字段可以保持缺省而不会引发 AttributeError;为这种情况添加或运行回归测试。
由索引模型根据 Issue 内容生成。
描述
Bug Report
Steps to Reproduce:
- Define a Rune type with an optional basic-type field such as DateWithMeta
(cardinality 0..1). - Construct an instance via init without providing the optional field —
pydantic calls the field's WrapValidator with obj=None. - Observe the exception.
Expected Result:
None is returned via handler(None), allowing the optional field to remain
absent.
Actual Result:
AttributeError is raised:
"'NoneType' object has no attribute '_init_meta'"
Environment:
rune-python-runtime 2.2.2, pydantic 2.14.1, Python 3.11
Additional Context:
Observed when constructing NonNegativeQuantitySchedule via init; bypassed
in tests using model_construct() to skip validation.
metadata.py BasicTypeMetaDataMixin.deserialize leaves model=obj (None) when
obj is neither a base type nor a dict, then unconditionally calls
model._init_meta(allowed_meta) if meta checks are enabled.
Fix: add if obj is None: return handler(None) as the first check.
import datetime
import pytest
from rune.runtime.metadata import DateWithMeta
def test_r5_basic_type_deserialize_none_raises_attribute_error():
'''Calling DateWithMeta.deserialize(None, ...) raises AttributeError
because model is left as None before _init_meta is called.'''
with pytest.raises(AttributeError, match='_init_meta'):
DateWithMeta.deserialize(
None,
lambda x: x,
(datetime.date, str),
set(),
)
- 主要语言
- Python
- 星标
- 0
- 派生
- 4
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
finos/rune-python-runtime 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
finos/rune-python-runtime#52 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
finos/rune-python-runtime#50 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
finos/rune-python-runtime#48 ·
-
难度 1/5 1 小时以内 新手友好度 84/100
finos/rune-python-runtime#47 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
finos/rune-python-runtime#43 ·
查看 finos/rune-python-runtime 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
slavakurilyak/awesome-ai-agents#845 ·
维护者通常 1 天内回复
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directory可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭difficulty:2 enhancement good first issue
难度 1/5 1-3 小时 新手友好度 92/100
MakazhanAlpamys/Soup#2178 ·
维护者通常 1 天内回复
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-values未关闭
难度 2/5 1-3 小时 新手友好度 75/100
scverse/rapids-singlecell#854 ·
维护者通常 1 天内回复
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGL可能已有人在做 @ninglinLiu 今天认领。 未关闭area:frontend backend:slang bug direction:input
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 13 天内回复