apache/superset · error

Failed to apply theme config: ${error.message}

Error message

Failed to apply theme config: ${error.message}

What it means

This is the embedded SDK's Switchboard method 'setThemeConfig': it forwards the host application's theme payload to ThemeController.setThemeConfig and, on any throw (invalid config, permission failure like 'User does not have permission to update the theme', mode constraints), rethrows wrapped as 'Failed to apply theme config: <cause>'. The cause message is the real diagnosis.

Source

Thrown at superset-frontend/src/embedded/index.tsx:317

    Switchboard.defineMethod('getDataMask', embeddedApi.getDataMask);
    Switchboard.defineMethod('getChartStates', embeddedApi.getChartStates);
    Switchboard.defineMethod(
      'getChartDataPayloads',
      embeddedApi.getChartDataPayloads,
    );
    Switchboard.defineMethod(
      'setThemeConfig',
      (payload: { themeConfig: SupersetThemeConfig }) => {
        const { themeConfig } = payload;
        log('Received setThemeConfig request:', themeConfig);

        try {
          const themeController = getThemeController();
          themeController.setThemeConfig(themeConfig);
          return { success: true, message: 'Theme applied' };
        } catch (error) {
          logging.error('Failed to apply theme config:', error);
          throw new Error(`Failed to apply theme config: ${error.message}`);
        }
      },
    );

    Switchboard.defineMethod(
      'setThemeMode',
      (payload: { mode: 'default' | 'dark' | 'system' }) => {
        const { mode } = payload;
        log('Received setThemeMode request:', mode);

        try {
          const themeController = getThemeController();

          const themeModeMap: Record<string, ThemeMode> = {
            default: ThemeMode.DEFAULT,
            dark: ThemeMode.DARK,
            system: ThemeMode.SYSTEM,
          };

View on GitHub (pinned to f4587218dd)

Solutions

  1. Read the suffixed cause in the error (e.g. permission or dark-theme message) and fix that underlying condition.
  2. Validate the themeConfig payload shape against SupersetThemeConfig before posting via embedSdk.send('setThemeConfig', ...).
  3. Ensure the embedded guest user has the theme permission when themes are meant to be host-controlled.
  4. Wrap the host-side send in .catch to degrade gracefully to the default theme.

Example fix

// before (host)
await embedSdk.send('setThemeConfig', { themeConfig });

// after (host)
try {
  await embedSdk.send('setThemeConfig', { themeConfig });
} catch (e) {
  console.warn('Theme not applied, falling back to default:', e.message);
}
Defensive patterns

Strategy: try-catch

Validate before calling

import type { SupersetThemeConfig } from '@superset-embedded-sdk';

function looksLikeThemeConfig(v: unknown): v is SupersetThemeConfig {
  return !!v && typeof v === 'object'; // extend with token shape checks as needed
}

if (!looksLikeThemeConfig(themeConfig)) return; // do not send

Type guard

function isThemeModePayload(v: unknown): v is { mode: 'default' | 'dark' | 'system' } {
  return (
    !!v && typeof v === 'object' &&
    ['default', 'dark', 'system'].includes((v as { mode?: string }).mode ?? '')
  );
}

Try / catch

// host side
try {
  const res = await embedSdk.send('setThemeConfig', { themeConfig });
} catch (e) {
  console.warn('Superset theme not applied:', (e as Error).message);
  // keep default theme; app continues
}

Prevention

When it happens

Trigger: Host app posts setThemeConfig with a malformed themeConfig object, a config the controller rejects, or while the guest/user lacks theme permission; also if the embedded guest bundle could not instantiate the ThemeController.

Common situations: Embedding SDK integration where the host sends a theme shaped for a different Superset version; token/guest permissions missing theme capability; typo in token names inside the theme payload.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/66a0c0fd7c0ccb9a. Report an issue: GitHub.