Skip to content

Read the member a parser JSON Pointer token names through the shared member reader, under the parser's own row - #5612

Merged
Koudai Aono (koxudaxi) merged 1 commit into
impl-mediafrom
impl-c01r
Oct 30, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
impl-mediafrom
impl-c01r

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Reference resolution now applies JSON Pointer array-index rules consistently when traversing lists. Invalid or excessively long indices are rejected, while out-of-range indices continue to follow the existing missing-reference behavior.
    • Pointer-based lookups now handle object members and array items consistently across document parsing and reference checks.
  • Documentation
    • Updated architecture documentation to clarify how document members are resolved during pointer traversal.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The pull request adds a refusing member-reading row to _document_reader.py and routes JSON Schema parser pointer traversal through it. It also updates architecture and decision-home records.

Changes: Shared JSON Pointer member reading

Layer / File(s) Summary
Add parser-specific member reading
src/datamodel_code_generator/_document_reader.py, docs/architecture.md, scripts/decision_homes.toml
The shared reader adds the refusing row, which reads mapping tokens and validates array-index tokens. Invalid indices raise Error, out-of-range indices raise ArrayIndexOutOfRangeError, and non-container values raise NotImplementedError. The architecture and decision-home records identify this reader and its index grammar.
Use shared member reading in JSON Schema traversal
src/datamodel_code_generator/parser/jsonschema.py
The parser uses member for decoded paths and pointer splitting. Fragment checks and reserved-target lookups use _fragment_value. Optional missing-value handling and out-of-range handling remain in the described paths.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to eff1f

The shared member reader preserves existing JSON Pointer behavior. No actionable merge-blocking issue was identified; merge after normal checks pass.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately describes the main change: parser JSON Pointer member reads now use the shared member reader under the parser-specific row. It is specific and related to the changeset, although s…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title accurately describes the main change: parser JSON Pointer member reads now use the shared member reader under the parser-specific row. It is specific and related to the changeset, although slightly awkward in phrasing.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files. (3 skipped: 2 unsupported, 1 too large.)

Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T01:07:49.944689Z eff1f92 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 30, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 31%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

❌ 52 regressed benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_load_yaml_openapi_large 19 ms 36 ms -47.28%
❌ test_perf_unique_items_nested_model_validation 1.6 ms 2.5 ms -38.16%
❌ test_perf_inherited_required_fields[required-derived-first] 351.3 ms 547.5 ms -35.84%
❌ test_perf_unique_items_runtime_scalar_validation 1.6 ms 2.5 ms -35.21%
❌ test_perf_inherited_required_fields[required-base-first] 303 ms 466 ms -34.99%
❌ test_perf_simple_pydantic_v2_field_construction 6 ms 9.3 ms -34.98%
❌ test_perf_false_reference_validation 124.7 ms 190.7 ms -34.58%
❌ test_perf_inherited_required_fields[partial-base-first] 492 ms 750.5 ms -34.44%
❌ test_perf_aws_style_openapi_pydantic_v2 1.1 s 1.7 s -34.27%
❌ test_perf_deep_nested 2.6 s 4 s -34.26%
❌ test_perf_openapi_large 1.6 s 2.4 s -34.24%
❌ test_perf_complex_refs 979.8 ms 1,487.3 ms -34.12%
❌ test_perf_stripe_style_pydantic_v2 1 s 1.5 s -33.9%
❌ test_perf_kubernetes_style_pydantic_v2 1.3 s 2 s -33.44%
❌ test_perf_large_models_typed_dict[total-false-requiredness] 556.3 ms 830.3 ms -33%
❌ test_perf_inherited_required_fields[partial-derived-first] 540.2 ms 803.4 ms -32.77%
❌ test_perf_duplicate_names 509.3 ms 756.3 ms -32.67%
❌ test_perf_large_models_dataclass_builtin 654.2 ms 970.9 ms -32.63%
❌ test_perf_target_render[fastapi-small] 11.2 ms 16.6 ms -32.56%
❌ test_perf_openapi_large_pydantic_v2_builtin 641.3 ms 950.5 ms -32.53%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing impl-c01r (eff1f92) with impl-media (a32edc2)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit 9644b20 into main Oct 30, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-c01r branch October 30, 2026 01:58
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The diff is an internal refactor that moves the RFC 6901 array index resolution from private helpers in parser/jsonschema.py into a new refusing row of the private _document_reader.member function, adding ArrayIndexOutOfRangeError there; _get_model_by_decoded_path, _split_json_pointer, _lenient_pointer_exists and _reserved_targets now call member or _fragment_value but keep the same semantics (missing dict key reads as an empty dict or the missing sentinel, invalid index raises Error, out of range index raises or becomes the sentinel under or_missing, non-container traversal raises NotImplementedError with the same message). Only private underscore-prefixed helpers were removed, a loop variable was renamed to avoid shadowing, and the remaining edits are architecture docs and the internal decision_homes.toml, so there are no CLI, public API, template, Python version or error handling changes. The behaviour diff gate compares against the last release, and its accepted cells are explicitly attributed to an earlier unrelated allOf change, empty object models becoming RootModel or aliases, which this diff does not touch; the remaining cells are crash-fix or both-fail, so no default output change is attributable to this PR.


This analysis was produced by the release draft workflow

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.88.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant