{"record":{"id":"66a0c0fd7c0ccb9a","repo":"apache/superset","slug":"failed-to-apply-theme-config-error-message","errorCode":null,"errorMessage":"Failed to apply theme config: ${error.message}","messagePattern":"Failed to apply theme config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"superset-frontend/src/embedded/index.tsx","lineNumber":317,"sourceCode":"    Switchboard.defineMethod('getDataMask', embeddedApi.getDataMask);\n    Switchboard.defineMethod('getChartStates', embeddedApi.getChartStates);\n    Switchboard.defineMethod(\n      'getChartDataPayloads',\n      embeddedApi.getChartDataPayloads,\n    );\n    Switchboard.defineMethod(\n      'setThemeConfig',\n      (payload: { themeConfig: SupersetThemeConfig }) => {\n        const { themeConfig } = payload;\n        log('Received setThemeConfig request:', themeConfig);\n\n        try {\n          const themeController = getThemeController();\n          themeController.setThemeConfig(themeConfig);\n          return { success: true, message: 'Theme applied' };\n        } catch (error) {\n          logging.error('Failed to apply theme config:', error);\n          throw new Error(`Failed to apply theme config: ${error.message}`);\n        }\n      },\n    );\n\n    Switchboard.defineMethod(\n      'setThemeMode',\n      (payload: { mode: 'default' | 'dark' | 'system' }) => {\n        const { mode } = payload;\n        log('Received setThemeMode request:', mode);\n\n        try {\n          const themeController = getThemeController();\n\n          const themeModeMap: Record<string, ThemeMode> = {\n            default: ThemeMode.DEFAULT,\n            dark: ThemeMode.DARK,\n            system: ThemeMode.SYSTEM,\n          };","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset-frontend/src/embedded/index.tsx#L299-L335","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the suffixed cause in the error (e.g. permission or dark-theme message) and fix that underlying condition.","Validate the themeConfig payload shape against SupersetThemeConfig before posting via embedSdk.send('setThemeConfig', ...).","Ensure the embedded guest user has the theme permission when themes are meant to be host-controlled.","Wrap the host-side send in .catch to degrade gracefully to the default theme."],"exampleFix":"// before (host)\nawait embedSdk.send('setThemeConfig', { themeConfig });\n\n// after (host)\ntry {\n  await embedSdk.send('setThemeConfig', { themeConfig });\n} catch (e) {\n  console.warn('Theme not applied, falling back to default:', e.message);\n}","handlingStrategy":"try-catch","validationCode":"import type { SupersetThemeConfig } from '@superset-embedded-sdk';\n\nfunction looksLikeThemeConfig(v: unknown): v is SupersetThemeConfig {\n  return !!v && typeof v === 'object'; // extend with token shape checks as needed\n}\n\nif (!looksLikeThemeConfig(themeConfig)) return; // do not send","typeGuard":"function isThemeModePayload(v: unknown): v is { mode: 'default' | 'dark' | 'system' } {\n  return (\n    !!v && typeof v === 'object' &&\n    ['default', 'dark', 'system'].includes((v as { mode?: string }).mode ?? '')\n  );\n}","tryCatchPattern":"// host side\ntry {\n  const res = await embedSdk.send('setThemeConfig', { themeConfig });\n} catch (e) {\n  console.warn('Superset theme not applied:', (e as Error).message);\n  // keep default theme; app continues\n}","preventionTips":["Pin the embedded SDK version to the matching Superset backend so theme payload shapes agree.","Log the cause suffix (permission vs config) to route the fix correctly.","Ensure guest tokens carry the theme capability when hosts control theming."],"tags":["embedded","theme","sdk","switchboard"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}