Repository navigation
Stop self-referencing nullable OpenAPI schemas from recursing when expanded - #4665
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 858f586 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
peterwhite
marked this pull request as ready for review
October 6, 2026 14:58
Contributor
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
nolannbiron
approved these changes
Oct 7, 2026
This branch was successfully 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.
Proposed changes
Fixes OpenAPI schemas that refer to themselves through a nullable array, like
AND: anyOf [array of FilterClause, null]. When expanded, they rendered forever and the server ran out of memory.The renderer stops at a circular schema by checking whether it has seen that exact object before.
normalizeNullableUnionmade a new copy every time, so the check never matched. It now returns the same object for the same schema.This only showed up with expanded sections, which means PDF export or specs that set
x-expandAllModelSections.Before the fix, rendering the schema used up a 4 GB heap in about 33 seconds. After, it takes 16 ms. A new test fails without the fix.
Rendered HTML is identical before and after for 787 operations across 11 specs that already worked.
The PDF export that was crashing now renders on this PR's preview: https://gitbook-v2-rhy0ixflo-gitbook.vercel.app/~space/iXVX3JFbIboip1Xtg1I6/~gitbook/pdf?back=false&only=yes&page=1ZWW21YhiWZACs4HynTk
Part of RND-13222.
How to reproduce
Add a spec with a self-referencing nullable schema to a space:
Add an OpenAPI block for an operation that uses
FilterClause.Export that page as PDF.
On
main, the export runs out of memory and every page stays on "Loading...". On this branch, it renders.Context
Problem: PDF exports that include these schemas run out of memory, and every page stays on "Loading...".
Outcome: The PDF export works.
Changelog