{"record":{"id":"90904b3b6c9dafd5","repo":"octobercms/october","slug":"cms-lang-theme-active-not-set","errorCode":null,"errorMessage":"cms::lang.theme.active.not_set","messagePattern":"cms::lang\\.theme\\.active\\.not_set","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"critical","filePath":"modules/cms/classes/Theme.php","lineNumber":194,"sourceCode":"        if ($apiResult !== null) {\n            return $apiResult;\n        }\n\n        // System edit site override, used for setting the active theme in the backend\n        if (App::runningInBackend() && ($siteTheme = Config::get('cms.edit_theme'))) {\n            return $siteTheme;\n        }\n\n        // Backend preference override, used for setting the preview theme in the editor\n        // @todo add a get variable check (_editor_preview)\n        if ($prefTheme = self::getEditThemeCodeFromPreference()) {\n            return $prefTheme;\n        }\n\n        // Config value, used for rendering the frontend\n        $activeTheme = Config::get('cms.active_theme');\n        if (!$activeTheme) {\n            throw new SystemException(Lang::get('cms::lang.theme.active.not_set'));\n        }\n\n        return $activeTheme;\n    }\n\n    /**\n     * getActiveTheme returns the active theme object\n     */\n    public static function getActiveTheme(): ?Theme\n    {\n        if (self::$activeThemeCache !== false) {\n            return self::$activeThemeCache;\n        }\n\n        $theme = static::load($themeCode = static::getActiveThemeCode());\n\n        if ($theme->isLocked()) {\n            throw new ApplicationException(Lang::get('cms::lang.theme.active.is_locked', ['theme' => $themeCode]));","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/classes/Theme.php#L176-L212","documentation":"SystemException thrown by `Theme::getActiveThemeCode()` when no active theme can be resolved at all: the site record has no theme, there is no backend preview-theme preference, and `cms.active_theme` config is empty/missing. Because every front-end request needs an active theme, this exception typically takes the whole public site down.","triggerScenarios":"Any front-end request on an installation where config/cms.php lacks 'active_theme', the .env value (CMS_ACTIVE_THEME) is unset, and the site row's theme column is null; after wiping the database while keeping code; config cache poisoned with a null value.","commonSituations":"Incomplete initial setup; environment variable missing in a new deploy environment; `php artisan config:cache` run with an empty env; site record created without a theme by a custom installer.","solutions":["Set the theme in config/cms.php: 'active_theme' => 'mytheme', or via .env CMS_ACTIVE_THEME=mytheme, then clear config cache.","Alternatively set the theme on the site record in the backend (Settings > Theme) which overrides config.","Confirm `themes/mytheme/` exists — a configured but missing theme resolves as invalid and leaves the code unset."],"exampleFix":"// .env / config/cms.php — before\nCMS_ACTIVE_THEME=\n\n// after — directory themes/mytheme must exist\nCMS_ACTIVE_THEME=mytheme\n// then: php artisan config:clear","handlingStrategy":"validation","validationCode":"// Boot-time guard (e.g. App boot or a health endpoint)\nif (!app()->runningInConsole() && !Config::get('cms.active_theme')) {\n    // fail with an actionable setup page instead of an uncaught SystemException\n    abort(503, 'No active theme configured. Set CMS_ACTIVE_THEME or choose a theme in the backend.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $theme = Theme::getActiveTheme();\n} catch (System\\Exception $e) {\n    // active theme unresolvable — render a maintenance/setup page, log for ops\n    Log::critical('Active theme not set');\n    return response()->view('errors.setup-required', [], 503);\n}","preventionTips":["Set CMS_ACTIVE_THEME in every environment's .env and template it in your provisioning.","Add 'active theme resolves' to deployment smoke tests after config:cache.","Never run config:cache in an environment where the env var is absent — the null gets baked in."],"tags":["theme","configuration","bootstrap","site-down","env-var"],"backgroundTag":"missing-configuration","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}