Skip to content

test: rethrow stack overflows in the sanity-bridge oracle reference - #3587

Merged
christianhg merged 1 commit into
mainfrom
test/bridge-oracle-overflow
Nov 4, 2026
Merged

christianhg merged 1 commit into
mainfrom
test/bridge-oracle-overflow

Conversation

@christianhg

@christianhg christianhg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

The cycle scenario in the sanity-bridge conversion oracle failed intermittently in CI with expected function to throw an error, but it didn't, on PRs that don't touch the bridge.

The test-only reference conversion reads array members through safeGetOf, which wrapped Sanity's lazy of getter in a bare catch. On the block to inline object to Portable Text field cycle, the stack can run out inside that getter, and the RangeError was swallowed. The recursion then returned early instead of overflowing, so toThrow(RangeError) failed. safeGetOf now rethrows a RangeError and keeps ignoring other getter errors. The fuzz rounds had the same gap: a swallowed overflow produced a truncated reference result to compare against, and now that round takes the existing overflow branch, which only asserts the rework terminates.

On Node 26.13.0 (the CI version) the oracle file failed 1 of 20 runs on main and 0 of 20 with the change. A getter that throws RangeError passes through safeGetOf with the change and is swallowed on main. Test-only, so no changeset.


Note

Low Risk
Test-only change to error handling in the oracle reference; no production bridge behavior.

Overview
Fixes intermittent CI failures in the conversion oracle where cyclic block ↔ inline-object schemas were supposed to overflow the recursive reference but sometimes did not throw.

In the test-only reference helper safeGetOf, the catch around Sanity’s lazy array of getter no longer swallows RangeError. Other getter errors are still ignored. When overflow happened inside the getter, swallowing it made recursion exit early, so toThrow(RangeError) and fuzz rounds that expect a reference crash could fail despite unrelated PRs.

Production conversion code is unchanged; only the oracle reference in sanity-schema-to-portable-text-schema.oracle.test.ts is updated.

Reviewed by Cursor Bugbot for commit ca754a1. Bugbot is set up for automated code reviews on this repo. Configure here.

The reference conversion's `safeGetOf` swallowed every error thrown by a schema getter, including a `RangeError` when the call stack ran out inside one. The recursion then returned early instead of overflowing, so the cycle scenario's `toThrow(RangeError)` failed on some runs. The fuzz rounds had the same hole: a swallowed overflow gave a truncated reference result to compare against.
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
portable-text-example-basic Ready Ready Preview Nov 4, 2026 3:01pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
portable-text-editor-documentation Skipped Skipped Nov 4, 2026 3:01pm UTC
portable-text-playground Skipped Skipped Nov 4, 2026 3:01pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – portable-text-playground November 4, 2026 15:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – portable-text-editor-documentation November 4, 2026 15:00 Inactive
@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ca754a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Stats

✅ No significant changes.

All scenario measurements (37)

🗺️ @portabletext/block-tools / @portabletext/block-tools · @portabletext/block-tools / @portabletext/block-tools/rules · @portabletext/editor / @portabletext/editor · @portabletext/editor / @portabletext/editor/behaviors · @portabletext/editor / @portabletext/editor/plugins · @portabletext/editor / @portabletext/editor/selectors · @portabletext/editor / @portabletext/editor/traversal · @portabletext/editor / @portabletext/editor/utils · @portabletext/editor / defineSchema · @portabletext/editor / useEditor · @portabletext/editor / typical · @portabletext/html / @portabletext/html · @portabletext/html / @portabletext/html/rules · @portabletext/html / htmlToPortableText · @portabletext/keyboard-shortcuts / @portabletext/keyboard-shortcuts · @portabletext/markdown / @portabletext/markdown · @portabletext/markdown / portableTextToMarkdown · @portabletext/patches / @portabletext/patches · @portabletext/repair / @portabletext/repair · @portabletext/sanity-bridge / @portabletext/sanity-bridge · @portabletext/schema / @portabletext/schema · @portabletext/plugin-character-pair-decorator / @portabletext/plugin-character-pair-decorator · @portabletext/plugin-decorations / @portabletext/plugin-decorations · @portabletext/plugin-dnd / @portabletext/plugin-dnd · @portabletext/plugin-emoji-picker / @portabletext/plugin-emoji-picker · @portabletext/plugin-input-rule / @portabletext/plugin-input-rule · @portabletext/plugin-list-index / @portabletext/plugin-list-index · @portabletext/plugin-markdown-shortcuts / @portabletext/plugin-markdown-shortcuts · @portabletext/plugin-one-line / @portabletext/plugin-one-line · @portabletext/plugin-paste-link / @portabletext/plugin-paste-link · @portabletext/plugin-sdk-value / @portabletext/plugin-sdk-value · @portabletext/plugin-typeahead-picker / @portabletext/plugin-typeahead-picker · @portabletext/plugin-typography / @portabletext/plugin-typography · @portabletext/toolbar / @portabletext/toolbar · @portabletext/toolbar / typical · @portabletext/plugin-table / @portabletext/plugin-table · @portabletext/plugin-table / @portabletext/plugin-table/ui · Artifacts

Scenario Kind Bundle (raw / gzip) Gzip change Import time Import change
⚪ @portabletext/block-tools / @portabletext/block-tools export 338.3 KB / 40.0 KB None 141 ms -2 ms, -1.2%
⚪ @portabletext/block-tools / @portabletext/block-tools/rules export 15.2 KB / 2.1 KB None 4 ms +0 ms, +0.4%
⚪ @portabletext/editor / @portabletext/editor export 1.02 MB / 130.3 KB None 56 ms -0 ms, -0.4%
⚪ @portabletext/editor / @portabletext/editor/behaviors export 4.3 KB / 147 B None 2 ms +0 ms, +0.6%
⚪ @portabletext/editor / @portabletext/editor/plugins export 5.1 KB / 645 B None 6 ms +0 ms, +1.0%
⚪ @portabletext/editor / @portabletext/editor/selectors export 96.3 KB / 9.4 KB None 6 ms -0 ms, -2.3%
⚪ @portabletext/editor / @portabletext/editor/traversal export 46.6 KB / 4.2 KB None 4 ms +0 ms, +0.2%
⚪ @portabletext/editor / @portabletext/editor/utils export 32.8 KB / 4.1 KB None 5 ms +0 ms, +0.1%
⚪ @portabletext/editor / defineSchema consumer 658 B / 69 B None None None
⚪ @portabletext/editor / typical consumer 1.02 MB / 130.0 KB None None None
⚪ @portabletext/editor / useEditor consumer 1.6 KB / 248 B None None None
⚪ @portabletext/html / @portabletext/html export 69.3 KB / 10.1 KB None 5 ms -0 ms, -0.3%
⚪ @portabletext/html / @portabletext/html/rules export 15.2 KB / 2.1 KB None 3 ms -0 ms, -1.2%
⚪ @portabletext/html / htmlToPortableText consumer 69.3 KB / 10.1 KB None None None
⚪ @portabletext/keyboard-shortcuts / @portabletext/keyboard-shortcuts export 7.0 KB / 858 B None 2 ms -0 ms, -0.4%
⚪ @portabletext/markdown / @portabletext/markdown export 425.4 KB / 66.1 KB None 30 ms -0 ms, -0.5%
⚪ @portabletext/markdown / portableTextToMarkdown consumer 338.8 KB / 56.3 KB None None None
⚪ @portabletext/patches / @portabletext/patches export 50.0 KB / 7.7 KB None 3 ms -0 ms, -4.7%
⚪ @portabletext/plugin-character-pair-decorator / @portabletext/plugin-character-pair-decorator export 124.1 KB / 15.8 KB None None None
⚪ @portabletext/plugin-decorations / @portabletext/plugin-decorations export 16.4 KB / 2.3 KB None None None
⚪ @portabletext/plugin-dnd / @portabletext/plugin-dnd export 10.4 KB / 1.8 KB None None None
⚪ @portabletext/plugin-emoji-picker / @portabletext/plugin-emoji-picker export 150.1 KB / 18.6 KB None None None
⚪ @portabletext/plugin-input-rule / @portabletext/plugin-input-rule export 124.2 KB / 15.8 KB None None None
⚪ @portabletext/plugin-list-index / @portabletext/plugin-list-index export 7.4 KB / 1.1 KB None None None
⚪ @portabletext/plugin-markdown-shortcuts / @portabletext/plugin-markdown-shortcuts export 136.4 KB / 17.6 KB None None None
⚪ @portabletext/plugin-one-line / @portabletext/plugin-one-line export 2.6 KB / 608 B None None None
⚪ @portabletext/plugin-paste-link / @portabletext/plugin-paste-link export 4.3 KB / 1.0 KB None None None
⚪ @portabletext/plugin-sdk-value / @portabletext/plugin-sdk-value export 242.1 KB / 32.8 KB None None None
⚪ @portabletext/plugin-table / @portabletext/plugin-table export 61.1 KB / 7.1 KB None None None
⚪ @portabletext/plugin-table / @portabletext/plugin-table/ui export 114.6 KB / 19.5 KB None None None
⚪ @portabletext/plugin-typeahead-picker / @portabletext/plugin-typeahead-picker export 166.1 KB / 19.9 KB None None None
⚪ @portabletext/plugin-typography / @portabletext/plugin-typography export 131.1 KB / 17.0 KB None None None
⚪ @portabletext/repair / @portabletext/repair export 4.5 KB / 636 B None 2 ms +0 ms, +3.0%
⚪ @portabletext/sanity-bridge / @portabletext/sanity-bridge export 275.1 KB / 30.2 KB None 136 ms +1 ms, +0.4%
⚪ @portabletext/schema / @portabletext/schema export 9.9 KB / 1.2 KB None 1 ms +0 ms, +1.2%
⚪ @portabletext/toolbar / @portabletext/toolbar export 153.3 KB / 17.3 KB None None None
⚪ @portabletext/toolbar / typical consumer 145.6 KB / 16.9 KB None None None

Significant means at least 1.0 KB and 1% gzip, or at least 5 ms and 10% import time.

@christianhg
christianhg merged commit 67c2bc1 into main Nov 4, 2026
22 checks passed
@christianhg
christianhg deleted the test/bridge-oracle-overflow branch November 4, 2026 15:06

This branch was successfully deployed

1 active and 2 inactive deployments
Preview – portable-text-example-basic — ca754a1f Deployed Nov 4, 2026 by vercel[bot]
Preview – portable-text-playground — ca754a1f Deployed Nov 4, 2026 by vercel[bot]
Preview – portable-text-editor-documentation — ca754a1f Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant