Repository navigation
fix(theme): prevent infinite recursion from self-referential discriminators - #1584
Merged
Merged
Conversation
…nators A schema whose `oneOf` branches each declare their own `discriminator` on the same property (with no explicit mapping) crashed the browser tab. `getDiscriminator` returns the discriminator of a nested branch by reference, and `DiscriminatorNode` mutates its `.mapping` while inferring variants from the parent `oneOf`. Because the branch owns that same discriminator object, its mapping ends up containing itself, so rendering the branch re-enters `DiscriminatorNode` with a self-referential mapping and recurses until the stack overflows. Clone the borrowed discriminator before attaching it so the inferred mapping stays local to the node. Adds a `recursiveDiscriminator` example spec that reproduces the pattern and a schema-snapshot entry. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Size Change: +7.23 kB (+0.31%) Total Size: 2.35 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Visit the preview URL for this PR (updated for commit 2771b82): (expires Thu, 06 Aug 2026 20:00:02 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bf293780ee827f578864d92193b8c2866acd459f |
📸 Visual Diff ReportSnapshot comparison against https://docusaurus-openapi.tryingpan.dev/
❌ 7 page(s) with visual regressions
|
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
/tests/deprecated-description
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
/tests/license-identifier-demo-api
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
/tests/license-rendered-via-spdx-identifier
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
/tests/license-rendered-via-url
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
/tests/license-url-demo-api
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
/tests/recursive-filter-api
| Prod | Preview | Diff |
![]() |
![]() |
![]() |
Updated at 2026-07-30T20:07:06.736Z · run 30576977084
This was referenced Jul 30, 2026
Merged
This branch was previously deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.





















Problem
OpenAPI operation pages froze and crashed the browser tab when a schema contained a
oneOfwhose branches each declare their owndiscriminatoron the same property, with no explicitmapping. This surfaced on Palo Alto Networks' DLP Data Profiles API docs (pan.dev/dlp/api/), where every Data Profiles operation renders a schema shaped like:Root cause
getDiscriminatorreturns a nested branch'sdiscriminatorby reference.DiscriminatorNodethen mutates that object's.mappingwhile inferring variants from the parentoneOf. Because a branch (e.g.DataPatternRuleItem) owns that same discriminator object, its inferred mapping ends up containing itself — so rendering the branch re-entersDiscriminatorNodewith a self-referential mapping and recurses until the stack overflows:Fix
Clone the borrowed discriminator before attaching it in
SchemaNode, so the inferred.mappingstays local to the current node instead of poisoning the shared branch schema:Testing
demo/examples/tests/recursiveDiscriminator.yamlreproducing the pattern, plus acreate-ruleentry in the schema-snapshot suite.DataProfilesspec: the traversal that previously overflowed the stack now completes in a bounded number of node visits.demoproduction build succeeds and the previously-crashing pages render the full schema tree (request body, response schema, discriminator tabs) in the browser.normalizeunit tests pass (30/30).🤖 Generated with Claude Code