{"record":{"id":"120ca6d63eb975c0","repo":"d2phap/ImageGlass","slug":"ige-unable-to-load-themefoldername-theme-pack","errorCode":null,"errorMessage":"IGE: Unable to load '{themeFolderName}' theme pack. Please make sure '{themeConfigPath}' file is valid.","messagePattern":"IGE: Unable to load '(.+?)' theme pack\\. Please make sure '(.+?)' file is valid\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Settings/Config_Static.cs","lineNumber":992,"sourceCode":"        if (!th.IsValid)\n        {\n            // 2. look for theme pack in the base dir\n            var baseThemeConfigPath = BHelper.BaseDir(Dir.Themes, themeFolderName);\n            th = await new IgTheme().LoadAsync(baseThemeConfigPath);\n\n            // 3. cannot find theme, use fall back theme\n            if (!th.IsValid && useFallBackTheme)\n            {\n                // 4. load default theme\n                baseThemeConfigPath = BHelper.BaseDir(Dir.Themes, Const.DEFAULT_THEME);\n                th = await new IgTheme().LoadAsync(baseThemeConfigPath);\n            }\n        }\n\n        // 5. throw error if theme is invalid\n        if (!th.IsValid && throwIfThemeInvalid)\n        {\n            throw new ArgumentException($\"IGE: Unable to load '{themeFolderName}' theme pack. \" +\n                $\"Please make sure '{themeConfigPath}' file is valid.\", nameof(themeFolderName));\n        }\n\n        return th;\n    }\n\n\n    /// <summary>\n    /// Gets control layout position.\n    /// </summary>\n    public static LayoutPosition GetControlLayout(LayoutControl control)\n    {\n        var defaultPos = control == LayoutControl.Toolbar\n            ? LayoutPosition.Top\n            : LayoutPosition.Bottom;\n\n\n        // 1. read control's layouts from setting","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Settings/Config_Static.cs#L974-L1010","documentation":"Thrown by Config_Static.LoadThemeAsync (the theme-load flow) when the requested theme pack fails validation (th.IsValid is false) after exhausting all fallbacks, including the default theme, and throwIfThemeInvalid is true. The message names the theme folder and the path of the theme config file (theme.json) so the user can find and fix it.","triggerScenarios":"Produced at Config_Static.cs:992 when th.IsValid is still false after: (1) loading the requested theme failed, (2) the default-theme fallback (if useFallBackTheme) also produced an invalid theme, and (3) the caller requested throwIfThemeInvalid. Reached via theme switching or startup theme load.","commonSituations":"User-installed a corrupt or partial theme pack (missing theme.json, missing required color keys, malformed JSON); a theme folder renamed/moved breaking the relative path; an incompatible theme built for an older ImageGlass theme schema (missing new required fields); the default theme pack itself was deleted from the Themes directory so the fallback also failed.","solutions":["Open the theme.json at the printed themeConfigPath and validate it is well-formed JSON with all required IgTheme fields.","Re-install or re-download the theme pack; if the folder was renamed, restore the original name referenced by Config.Theme.","If the default theme is also failing, reinstall ImageGlass to restore the shipped default theme pack under Dir.Themes/Const.DEFAULT_THEME.","Switch Config.Theme back to the default theme name (or delete the user theme preference) so startup uses the shipped default."],"exampleFix":"// before\nif (!th.IsValid && throwIfThemeInvalid)\n    throw new ArgumentException($\"IGE: Unable to load '{themeFolderName}' theme pack. \" +\n        $\"Please make sure '{themeConfigPath}' file is valid.\", nameof(themeFolderName));\n\n// after — include the specific validation failure so the user knows what to fix\nif (!th.IsValid && throwIfThemeInvalid)\n    throw new ArgumentException(\n        $\"IGE: Unable to load '{themeFolderName}' theme pack. \" +\n        $\"Please make sure '{themeConfigPath}' file is valid. \" +\n        $\"Validation errors: {string.Join(\"; \", th.ValidationErrors)}\",\n        nameof(themeFolderName));","handlingStrategy":"validation","validationCode":"// Before requesting a theme, confirm the folder and theme.json exist.\nvar themeConfigPath = BHelper.BaseDir(Dir.Themes, themeFolderName, Const.THEME_CONFIG_FILE);\nif (!File.Exists(themeConfigPath)) return GetDefaultTheme();\nvar json = File.ReadAllText(themeConfigPath);\nif (string.IsNullOrWhiteSpace(json) || JsonDocument.Parse(json).RootElement.ValueKind != JsonValueKind.Object)\n    return GetDefaultTheme();","typeGuard":"static bool ThemeConfigLooksValid(string path)\n{\n    if (!File.Exists(path)) return false;\n    try { using var d = JsonDocument.Parse(File.ReadAllText(path)); return d.RootElement.ValueKind == JsonValueKind.Object; }\n    catch { return false; }\n}","tryCatchPattern":"try { return await Config.LoadThemeAsync(name, throwIfThemeInvalid: true); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Unable to load\") && ex.Message.Contains(\"theme pack\"))\n{ _log.Warn($\"Theme load failed: {ex.Message}\"); return await Config.LoadThemeAsync(Const.DEFAULT_THEME, throwIfThemeInvalid: false); }","preventionTips":["Always keep the shipped default theme pack intact so the fallback in step 3 succeeds.","Validate theme.json structure (well-formed JSON object with required IgTheme keys) before loading.","Do not rename theme folders after the user selects them; resolve paths through BHelper.BaseDir.","On load failure, fall back to the default theme rather than throwing the user out."],"tags":["theme","config","ui","settings","startup"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}