Skip to content

Name the declaration of a referenced path item in the error for a non-string additionalOperations key - #5254

Merged
Koudai Aono (koxudaxi) merged 1 commit into
fix-5212-option-warning-exitfrom
review-fix-6
Oct 24, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
fix-5212-option-warning-exitfrom
review-fix-6

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Invalid method names in referenced OpenAPI path items now point to the declaration’s location in the error message, rather than the location where the path item is used.
    • Error messages for non-string method names in additionalOperations now identify the relevant component path and include the invalid value.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 8ec1cdc0b3b87a23c164e082fb4176f084111378 and d67d48e9e51bce13877e63cacf8d469819b163f7.

⛔ Files ignored due to path filters: 1
  • tests/data/malformed/integer_additional_operation_ref.yaml is excluded by !tests/data/**/*.yaml and included by none
📒 Files selected for processing: 2
  • src/datamodel_code_generator/parser/openapi_scope.py
  • tests/main/test_error_messages.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The OpenAPI scope validator now reports non-string method-key errors at the referenced path-item declaration. Invalid webhook-prefix errors remain tied to the use site. A regression test checks the diagnostic path and message for an integer additionalOperations key.

Changes: OpenAPI path-item error locations

Layer / File(s) Summary
Operation-name validation and diagnostic test
src/datamodel_code_generator/parser/openapi_scope.py, tests/main/test_error_messages.py
The validator uses the path-item declaration for non-string method-key errors. A regression test checks the component path and error message for an integer method key.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Possibly related issues

  • Issue 4981 tracks missing document-location context in API errors from parser/openapi_scope.py. This change reports the referenced path-item declaration location for non-string method keys.

Possibly related PRs

Merge Risk: ⚪ Minimal · up to d67d4

The change improves error locations for referenced path items without an identified behavioral regression. It is mergeable subject to normal checks.

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 clearly and specifically describes the main change: include the declaration name of a referenced path item in the error for a non-string additionalOperations key.
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. Analyzed 3 functions across 2 files.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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 23, 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-23T19:07:10.677001Z d67d48e 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 23, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 16.02%

1 warning

⚠️ 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

❌ 1 regressed benchmark
✅ 49 untouched benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_recommend_options_full_kubernetes_style 21.6 s 25.7 s -16.02%

Tip

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


Comparing review-fix-6 (9d83534) with fix-5212-option-warning-exit (19e37f9)

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 23, 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 50fecf5 into main Oct 24, 2026
131 of 132 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the review-fix-6 branch October 24, 2026 01:42
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The PR changes only the private method _validate_operation_name_keys in the OpenAPI scope parser, adding a declaration argument. When a non-string additional operation method is found in a path item reached through a reference, the error now gives the schema path where the path item is declared instead of the path that references it. This fixes the location shown for malformed input. It does not change generated code, templates, CLI options, the public Python API, defaults, supported Python versions, or whether an error is raised. The rest of the PR is a new malformed test fixture and a test case.


This analysis was produced by the release draft workflow

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