fix: authored-link normalization JSX range matching - #124
Closed
mvvmm wants to merge 3 commits into
Closed
Conversation
commit: |
MohamedH1998
reviewed
Sep 8, 2026
| // The TypeScript parse could not reconcile this attribute with the | ||
| // mdast node (for example, the raw slice spans blockquote markers that | ||
| // are not valid JSX). Skip it rather than failing the whole source. | ||
| continue; |
Collaborator
There was a problem hiding this comment.
Should we only normalize href on native elements? If a native html cannot be read, might be worth returning an error instead of skipping it.
Collaborator
|
Closing this as it's resolved by #138 |
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.
What & why
Bumping
@cloudflare/nimbus-docsto0.13.1incloudflare-docsfails atastro checkwithNimbus authored-link normalization failed ... ambiguous JSX range— 364 of 9309 MDX files crash.Root cause:
staticHrefOffsetsre-parses each JSX element's raw text as TSX and matches the TypeScript-computed node range against satteri's mdast position. TypeScript'sJsxElement.getEnd()includes trailing trivia (and even the wrapper's);), so the end offset drifts and the lookup misses → "ambiguous JSX range". The same raw text also isn't always valid JSX: code blocks inside JSX elements can contain{(interpreted by TS as a JSX expression) and blockquote markers (>) span the element's raw slice.Changes:
getStart()is precise and unique; the driftinggetEnd()was the failure.hrefattributes before the TS round-trip —staticHrefOffsetsonly ever emits insertions forhref-like attributes, so parsing is unnecessary (and crash-prone) otherwise.Verified: full scan of
cloudflare-docsdocs/partials/changelog goes from 364 failures to 0. Three regression tests added.Checklist
lgtm+on my issue or discussion), or I'm on the teampackages/nimbus-starter-source/, not thetemplatesbranchcreate-nimbus-docschangeset if the starter changed)pnpm typecheck,pnpm -r test, andpnpm templates:checkall green