Repository navigation
portal: an operation page crashes when a response example has no value #370
Description
Summary
An operation page in the portal fails to render when one of its response examples has no value. The whole page is replaced with:
Something went wrong!
Cannot read properties of undefined (reading 'split')
An Example Object with no value is valid OpenAPI 3.0/3.1, since every field on it is optional. The portal should render the rest of the page and skip or blank that example.
Reproduction
Found with a customer spec under apimatic portal serve. The spec below isolates the one construct that triggers it: the 200 response has two named examples, and the first one is {}.
{
"openapi": "3.0.0",
"info": { "title": "Repro", "version": "1.0.0" },
"paths": {
"/items": {
"get": {
"operationId": "listItems",
"tags": ["items"],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": { "type": "object" },
"examples": {
"Default": {},
"Populated": { "value": { "id": "1" } }
}
}
}
}
}
}
}
}
}Run apimatic portal serve and open the operation's page.
Actual: the page shows "Something went wrong!" with the error above. The browser console reports The above error occurred in the <Placeholder> component from fumadocs-ui/dist/components/dynamic-codeblock.core.js.
Expected: the operation page renders. The value-less example is either left out of the response accordion or shown as empty.
Cause
The crash is in fumadocs code that the portal template uses without a guard (fumadocs-openapi 11.4.1, fumadocs-ui 16.15.8):
ResponseTabs(fumadocs-openapi/dist/ui/operation/response-tabs.js) pushes one entry per named example withsample: getRaw(example.value). That isundefinedfor{}.renderExampleContentpassescode: JSON.stringify(example.sample, null, 2)toClientCodeBlock.JSON.stringify(undefined)returnsundefined, not a string.DynamicCodeBlockrendersPlaceholderwhile Shiki loads, andPlaceholdercallscode.split("\n"), which throws.- No route sets an
errorComponent, so the error reaches TanStack Router's rootCatchBoundaryand the whole page is lost.
The template's own renderAPIExampleUsageTabs (portal-template/src/components/usage-tabs.tsx) isn't involved. It is the response tabs that break.
Fix
- In
portal-template/src/components/api-page.tsx, drop examples whosevalueisundefinedbefore they reach the code block. This can be arenderResponseTabsoverride, or arenderCodeBlockthat renders nothing whencodeisn't a string. - Report the missing guard to fumadocs-openapi.
- Consider an
errorComponenton the operation route, so one broken section doesn't take down the whole page.
Activity
github-actions commentedon Sep 28, 2026
🎉 This issue has been resolved in version 2.0.0-beta.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
fix(portal): drop the code block guard Fumadocs 12.1 makes unnecessary (