Repository navigation
fix(portal): report content pages that are not valid MDX before the build or preview reaches them - #447
Open
mehnoorsiddiqui wants to merge 1 commit into
Open
fix(portal): report content pages that are not valid MDX before the build or preview reaches them#447mehnoorsiddiqui wants to merge 1 commit into
mehnoorsiddiqui wants to merge 1 commit into
Conversation
…uild or preview reaches them An `.mdx` page that is not valid MDX, such as an unclosed `<Cards>` or a mismatched closing tag, is now refused by `portal generate` and `portal serve`, at startup and on save. Every broken page is listed in one run, by its path in `src`, line and column, in MDX's own words without the bundler's internals. MDX stops at the first mistake in a page, and the message says so. Closes #443 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mehnoorsiddiqui
requested review from
Shield-Jaguar and
saeedjamshaid
as code owners
October 22, 2026 09:23
|
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.



Closes #443
The problem
A content page that is not valid MDX (an unclosed
<Cards>, a mismatched closing tag, a broken{…}expression) reached the author too late, or in a form they could not act on:portal servestarted without a word. The browser showed "Failed to fetch dynamically imported module", and the real cause was only in the body of a 500 response. Vite did log it, but the CLI does not show the dev server's output.portal generatefailed, but showed the raw tail of the build log: only the first broken page, under the project's temporary path, with bundler internals such as[plugin fumadocs-mdx:mdx],?macro_id=…anderrors: [Getter/Setter].What changes
The CLI already parses every content page the way the build does, to check its front matter and images. It now also reports where an
.mdxpage stops being valid MDX:portal generateandportal serverefuse such pages at startup, before Vite is involved.servechecks again on every save incontent/. A refused save leaves the last version the preview accepted in place.Every broken page is listed in one run, with its path relative to
src, and the line and column. MDX's own wording is kept, without the parser's internal names:MDX only notices an unclosed tag at the end of the page. It reports no location on the error and puts the tag's position in the message text instead, so the CLI reads the position from there. The page is reported at the tag's own line.
Not covered
<Cards>reports one, and the next appears once that one is fixed. The message says so. Listing every unclosed tag would need a tag-matching pass of our own, outside MDX, which could disagree with it.servedoes not start over broken content. It reports the problem and exits, as it already does for other content problems.How it was tested
.mdxand.mdpages), for the content check, forPortalSourceContextat startup and on a save that is later fixed, and for the message.npm testpasses, ESLint is clean, andAPIMATIC_E2E=1passes forportal-buildandportal-serve, so every page in the existing fixtures passes the new check.remark-mdx3.1.1 and the same micromark extensions that@mdx-js/mdx3.1.1 uses in the build, so both find the same syntax errors.🤖 Generated with Claude Code