Skip to content

portal: an operation page crashes when a response example has no value #370

Closed

Description

@mrafnadeem-apimatic

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):

  1. ResponseTabs (fumadocs-openapi/dist/ui/operation/response-tabs.js) pushes one entry per named example with sample: getRaw(example.value). That is undefined for {}.
  2. renderExampleContent passes code: JSON.stringify(example.sample, null, 2) to ClientCodeBlock. JSON.stringify(undefined) returns undefined, not a string.
  3. DynamicCodeBlock renders Placeholder while Shiki loads, and Placeholder calls code.split("\n"), which throws.
  4. No route sets an errorComponent, so the error reaches TanStack Router's root CatchBoundary and 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 whose value is undefined before they reach the code block. This can be a renderResponseTabs override, or a renderCodeBlock that renders nothing when code isn't a string.
  • Report the missing guard to fumadocs-openapi.
  • Consider an errorComponent on the operation route, so one broken section doesn't take down the whole page.

Activity

  1. github-actions commented on Sep 28, 2026

    @github-actions

    🎉 This issue has been resolved in version 2.0.0-beta.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions