You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Name --dedupe-request-response-variants in the errors that the 0.86.0 request-response decisions raise - #6208
Improved diagnostics for schemas that cannot be resolved when generating separate request and response models. Messages now point to the option that can enable deduplication of those variants.
Corrected generation for discriminated unions whose enum tags are referenced indirectly.
… request-response facts raise
Without --dedupe-request-response-variants the read/write facts of a key come from a temporary parse and the walk reads
every reference of a key, as in 0.86.0 (`legacy-rw-parsed-facts`, `legacy-rw-unowned-parent-fields`, both kept). An input
those reads stop on stopped with the bare error of the read, or with a traceback.
An error raised by the walk of the references of a key (`Unresolved $id reference '#node'` for a `$dynamicRef` inside an
`$id`d `$defs` entry) or by the lookup of the source of a variant (`$ref file not found: <dir>/p` for an allOf child
defined before its base, whose parent's inline model is parsed at no owner path) now ends with the hint that
`--dedupe-request-response-variants` decides the variants from the schema graph and can generate such schemas. The error
for classes that cannot be ordered under request-response is an `Error`, so the command line prints its message instead
of a traceback, and it lists the references of each class in sorted order, so its text no longer changes between runs
with the hash seed. The graph node of a special path is read in one place for both modes: a path the parser makes names no
schema of any document, so the walk reads nothing there (#5706 stopped with `NotImplementedError` until #6006; a test
pins the server and request-response run).
Only the text of an error and the type of the error for unordered classes change; no input that generated stops, and the
output of every input that generates is unchanged.
Fixes: #5266Fixes: #5556Fixes: #5570Fixes: #5613Fixes: #5706
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.
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.
Walkthrough
The changes update unresolved-reference diagnostics and legacy request/response variant analysis. They sort and deduplicate unresolved paths, add deduplication-option guidance to selected errors, and add regression tests for schema generation and FastAPI output.
Unresolved-reference paths are sorted and deduplicated. When legacy request/response mode is active, the unresolved-model error includes guidance about --dedupe-request-response-variants. Regression tests cover three schema cases both without and with deduplication enabled.
Legacy graph lookups add the deduplication hint to propagated errors. Special paths return no reference facts. The FastAPI regression test checks generated output for a discriminated enum.
The changes improve request-response diagnostics and special-path handling, with regression coverage for the affected scenarios. No merge-blocking issue is established.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Linked Issues check
Assessed against #5266, #5556, #5570, #5613, and #5706. No repository inspection was possible. This result relies on the supplied summary, the PR objectives, and the test expectations described in the…
Choose one of two remediations. (a) Make the legacy request-response read path generate output for the #5266, #5556, and #5570/#5613 inputs without --dedupe-request-response-variants. Generate the request and response variants, as the issue…
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly identifies the main change: adding --dedupe-request-response-variants to relevant request-response error messages. It is specific and related to the pull request.
Out of Scope Changes check
The reviewed changes connect to the linked issues or to their tests. - parser/_passes/_shared.py: with_dedupe_request_response_hint adds the hint text used by the new error messages for #5570 and #561…
Docstring Coverage
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…
Full details: Out of Scope Changes check
Explanation
The reviewed changes connect to the linked issues or to their tests.
parser/_passes/_shared.py: with_dedupe_request_response_hint adds the hint text used by the new error messages for #5570 and #5613.
parser/_passes/settle.py: sort_data_models replaces unresolved_hint with legacy_request_response. Reference paths are sorted and deduplicated for #5570 and #5613. The flag is set only when read/write variants are enabled and deduplication is off.
parser/_rw_split.py: legacy_rw_errors wraps legacy reference-fact reads and the variant-source schema check. It re-raises errors as Error with the hint. Special-path handling supports #5706.
tests/api_generation/test_fastapi_cli.py and its .refs file, with the matching expected output: regression coverage for #5706.
tests/main/test_error_messages.py and its .refs file, with the matching expected outputs: regression coverage for #5266, #5556, #5570, and #5613.
The ignored input fixtures under tests/data/malformed/ and tests/data/generation_platform/ are test inputs. They are excluded from review, and this result does not depend on their contents. No unrelated behavior change appears in the summary.
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 8 functions across 9 files. (2 skipped: 2 unsupported.)
Full details: Linked Issues check
Explanation
Assessed against #5266, #5556, #5570, #5613, and #5706. No repository inspection was possible. This result relies on the supplied summary, the PR objectives, and the test expectations described in the summary.
Partly met:
[#5570, #5613] Reference lists in the unresolved-class error are sorted and deduplicated (settle.py). The error now names --dedupe-request-response-variants. The error text is stable, but the generation requirement is not met (see below).
[#5706] Special parser paths are excluded from the variant graph walk, and reference-fact lookup returns (False, ()) for them. A new FastAPI CLI test covers a discriminated enum with a server target, and its expected output shows generation succeeds. This appears to meet #5706.
Unmet:
[#5266, #5556, #5570, #5613] All four issues require generation to succeed with --read-only-write-only-model-type request-response, without any extra option. Their reproduction commands do not include --dedupe-request-response-variants. The updated tests/main/test_error_messages.py cases expect the legacy request-response path to still raise errors for the #5266 (allOf child before base), #5556 ($dynamicRef in $id'd $defs), and #5570/request-response split of a recursive discriminated union fails with unresolved classes, in a message whose order varies between runs #5613 (recursive discriminator) fixtures. The generation success is expected only when the option is enabled. The PR objectives also state that the change alters only error text. The linked issues therefore remain unfixed in the default mode.
Resolution
Choose one of two remediations.
(a) Make the legacy request-response read path generate output for the #5266, #5556, and #5570/#5613 inputs without --dedupe-request-response-variants. Generate the request and response variants, as the issues specify. Update the three expected outputs and the test_error_messages.py cases to expect success. Keep the sorted, hinted error text only for inputs that still cannot be resolved.
(b) If the maintainers keep the option-only behavior, remove Fixes: #5266, #5556, #5570, and #5613 from the PR description. Keep those issues open, and retain only #5706 as fixed. Record the option-only behavior in the issues.
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.
⚠️52 benchmarks with a significant change ran on different hardware
Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.
No successful run was found on bug-g10 (c820a3f) during the generation of this report, so 94c7314 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Reasoning: The PR only touches the legacy read/write split path, which runs when --read-only-write-only-model-type request-response is used without --dedupe-request-response-variants. First, the _is_special_path check moves into get_ref_schema_rw_model_reference_facts. The legacy path now skips parser-made marker paths instead of crashing with NotImplementedError on discriminated unions with enum tags, so this is a crash fix. Second, the internal sort_data_models in the private parser._passes.settle module swaps its unresolved_hint string parameter for a legacy_request_response bool. That module is not public API. Third, the unresolved-classes error now lists references in sorted order for deterministic text. In legacy request-response mode it is raised as datamodel_code_generator.Error rather than a bare Exception. Error is a subclass of Exception, so existing handlers still catch it, and the dedupe hint text was already appended before. Fourth, a new legacy_rw_errors context manager adds the same dedupe-option hint to Error messages raised by reference-fact reads in legacy mode, which only adds text. The behaviour diff gate shows only both-fail, crash-fix and no-behaviour cells and no accepted or violation cells, so default generated output does not change. No CLI options, public API, templates, default values or Python version support were removed or changed. All other changes are new tests and fixtures.
This analysis was produced by the release draft workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #5266
Fixes: #5556
Fixes: #5570
Fixes: #5613
Fixes: #5706
Summary by CodeRabbit