Iterator error contexts lose parent links and absolute paths
@DawnofGenX 已经在做这个了。
开始于 2026年10月5日。
评估
调研方向
首先定位 ValidationError 和 SchemaError 构造函数,并复现 issue 中的迭代器示例。检查现有的回归测试,以了解上下文和 parent 行为,然后为这两个错误类分别覆盖一次性迭代器上下文,以及列表和元组上下文。完成的标准是子项保留其 parent 链接,并生成包含 parent 路径的绝对路径。
由索引模型根据 Issue 内容生成。
描述
Problem
Passing an iterator as ValidationError(context=...) retains its children, but does not set their parent. The iterator is consumed by self.context = list(context), then iterated again when assigning parents. This also affects SchemaError.
from jsonschema.exceptions import ValidationError
child = ValidationError("child", path=["name"], schema_path=[0, "type"])
parent = ValidationError(
"parent",
path=["record"],
schema_path=["properties", "record", "anyOf"],
context=iter([child]),
)
print(parent.context == [child]) # True
print(child.parent is parent) # False (expected True)
print(child.json_path) # $.name (expected $.record.name)
Lists and tuples assign the parent correctly. Setting parents from the stored self.context instead of the original iterable should preserve the same behavior for one-shot iterators.
Reproduced on main (51cd75e39), macOS, Python 3.12.13. A regression test fails for iterator contexts with both error classes and passes for list/tuple contexts.
Investigated with Codex assistance.
- 主要语言
- Python
- 星标
- 5k
- 派生
- 694
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-jsonschema/jsonschema 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
python-jsonschema/jsonschema#1588 · 2 条评论 ·
-
regex format checker crashes with RecursionError on deeply nested patterns可能已有人在做 @DawnofGenX 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
python-jsonschema/jsonschema#1538 · 1 条评论 ·
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponent可能重新可做 关联的 PR 已关闭且未合并。 未关闭Needs Test Upstream
难度 2/5 1-3 小时 新手友好度 78/100
python-jsonschema/jsonschema#1511 · 1 条评论 ·
-
regex format checker crashes with ValueError on conflicting inline flags可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
python-jsonschema/jsonschema#1558 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
python-jsonschema/jsonschema#1547 ·
查看 python-jsonschema/jsonschema 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
Deltares/imod-python#1940 ·
维护者通常 1 天内回复
-
effort: low prio: low ready
难度 1/5 1 小时以内 新手友好度 82/100
digitalfabrik/integreat-cms#4621 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
ioos/compliance-checker#1375 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复