mui/material-ui · error · Error

Could not find the MUI Chat URL, please open a new issue on

Error message

Could not find the MUI Chat URL, please open a new issue on https://github.com/mui/material-ui/issues/new

What it means

Thrown inside the docs sandbox helper when a user clicks 'Open in MUI Chat' but the `MUI_CHAT_API_BASE_URL` environment variable is unset. The variable is read at click time from process.env, so a missing value means the docs build was never given the Chat backend endpoint. The message directs users to file an issue because, in production, this value is injected at build time.

Source

Thrown at packages-internal/core-docs/src/Demo/sandbox/MuiChat.ts:34

export function createMuiChat(demoData: DemoData, csbConfig?: SandboxConfig) {
  const { title, githubLocation: description } = demoData;
  const ext = getFileExtension(demoData.codeVariant);

  // Get dependencies like StackBlitz
  const { dependencies } = SandboxDependencies(demoData, {
    commitRef: process.env.PULL_REQUEST_ID ? process.env.COMMIT_REF : undefined,
    csbConfig,
  });

  return {
    title,
    description,
    dependencies,
    openSandbox: async () => {
      const baseUrl = process.env.MUI_CHAT_API_BASE_URL;

      if (!baseUrl) {
        throw new Error(
          'Could not find the MUI Chat URL, please open a new issue on https://github.com/mui/material-ui/issues/new',
        );
      }

      // Use primaryPackage from context config, or fall back to legacy productId mapping
      let primaryPackage = csbConfig?.primaryPackage;
      if (!primaryPackage) {
        const productToPackage: Record<string, string> = {
          'material-ui': '@mui/material',
          'x-data-grid': '@mui/x-data-grid',
          'x-date-pickers': '@mui/x-date-pickers',
          'x-tree-view': '@mui/x-tree-view',
          'x-charts': '@mui/x-charts',
        };
        primaryPackage =
          (demoData.productId && productToPackage[demoData.productId]) || '@mui/material';
      }

View on GitHub (pinned to bdc96df2cb)

Solutions

  1. If you maintain the docs stack, set MUI_CHAT_API_BASE_URL in the docs dev/preview environment (e.g. export it in your shell or .env.local).
  2. If you are a consumer, this is not actionable — file the issue as the message instructs, or use the CodeSandbox/StackBlitz buttons instead.
  3. Verify the variable is present in the build by printing process.env.MUI_CHAT_API_BASE_URL in a throwaway log before the check.

Example fix

// before: env var unset, click throws
// after (docs contributor shell)
export MUI_CHAT_API_BASE_URL=https://chat.example.com
pnpm docs:dev
Defensive patterns

Strategy: validation

Validate before calling

// In the docs app, guard before exposing the MUI Chat button.
const chatEnabled = Boolean(process.env.MUI_CHAT_API_BASE_URL);
// render the Chat button only when chatEnabled is true

Try / catch

try {
  await openSandbox();
} catch (e) {
  if (/Could not find the MUI Chat URL/.test(e.message)) {
    // hide the Chat entrypoint and fall back to CodeSandbox/StackBlitz
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking `openSandbox()` on a demo's MUI Chat sandbox in a locally run docs server (`pnpm docs:dev`) without exporting MUI_CHAT_API_BASE_URL, or running a forked/preview build that did not receive the secret env injection.

Common situations: Local development of the docs site; CI preview builds that intentionally strip internal URLs; running the docs in an environment that does not have access to the MUI internal API.

Related errors


AI-assisted analysis of mui/material-ui@bdc96df2cb (2026-08-12). Data as JSON: /api/errors/79b12f4f7c00b79b. Report an issue: GitHub.