← Back to Pull requests

fix: allow allOf diamond under a discriminator parent #25877

Open
unknown opened this pull request with 407 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 30, 2026 09:09 UTC
Author

With legacyDiscriminatorBehavior=false (java, go, csharp...) spec from #13714 fails with Stack overflow hit when looking for Type, an infinite loop starting and ending at ResponseDetails was seen. UpdateDetails is allOf CreationDetails and ResponseDetails is allOf both, so getAllOfDescendants reaches ResponseDetails second time from UpdateDetails and throws, but its a diamond, not a loop. #17905 is same shape

Now repeat throws only when child is current schema or one of its allOf ancestors (real cycle), other repeats are skipped. Real cycle (A allOf [Type, B], B allOf [A]) still throws, also when its schemas are first reached thru diferent parents. Repeat check also compares schema name now, mapping name differs from it with x-discriminator-value. Added test in DefaultCodegenTest, regenerated all samples: no changes

Fixes #13714
Fixes #17905

PR checklist

  • Read the contribution guidelines.

  • Run the following to build the project and update samples:

  •   ./mvnw clean package || exit
      ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
      ./bin/utils/export_docs_generators.sh || exit
      

    Commit all changed files.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
  • <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Fixes stack overflow when allOf schemas form a diamond under a discriminator parent. With legacyDiscriminatorBehavior=false, schemas like UpdateDetails (allOf CreationDetails) and ResponseDetails (allOf both) previously triggered the infinite-loop check even though the relationship is a diamond, not a cycle.

    The traversal now remembers which schema each descendant was first reached from and skips repeats reached through other parents (diamonds). It only raises the infinite-loop error when the descendant is the current schema or one of its ancestors, and isAllOfAncestorOrSelf walks every allOf ancestor path so real cycles (e.g., CycleA allOf CycleB, CycleB allOf CycleA) still throw even when a schema is first reached through a different parent. The repeat check now compares schema names instead of mapping names, since x-discriminator-value can differ.

    Fixes #13714 and #17905.

    <sup>Written for commit 5e6bdfddf503ea06a5cccf0ccc105afac326b350. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/OpenAPITools/openapi-generator/pull/25877?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 407 lines (+305 / -102) across 5 files Reviewer: thekhegay Review duration: 437m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 407 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #25877"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%