{"record":{"id":"1a4e926b2566d6b4","repo":"d2phap/ImageGlass","slug":"unable-to-load-themefoldername-theme-pack-ple","errorCode":null,"errorMessage":"Unable to load '{themeFolderName}' theme pack. Please make sure '{themeConfigPath}' file is valid.","messagePattern":"Unable to load '(.+?)' theme pack\\. Please make sure '(.+?)' file is valid\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"v9/Components/ImageGlass.Settings/Config.cs","lineNumber":1645,"sourceCode":"\n            // cannot find theme, use fall back theme\n            if (!th.IsValid && useFallBackTheme)\n            {\n                th.Dispose();\n                th = null;\n\n                // load default theme\n                th = new(App.StartUpDir(Dir.Themes, Const.DEFAULT_THEME));\n            }\n        }\n\n\n        if (!th.IsValid && throwIfThemeInvalid)\n        {\n            th.Dispose();\n            th = null;\n\n            throw new InvalidDataException($\"Unable to load '{themeFolderName}' theme pack. \" +\n                $\"Please make sure '{themeConfigPath}' file is valid.\");\n        }\n\n        return th;\n    }\n\n\n    /// <summary>\n    /// Triggers <see cref=\"RequestUpdatingTheme\"/> event.\n    /// </summary>\n    public static void TriggerRequestUpdatingTheme()\n    {\n        RequestUpdatingTheme?.Invoke(new RequestUpdatingThemeEventArgs(Config.Theme));\n    }\n\n\n    /// <summary>\n    /// Triggers <see cref=\"RequestUpdatingLanguage\"/> event.","sourceCodeStart":1627,"sourceCodeEnd":1663,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/v9/Components/ImageGlass.Settings/Config.cs#L1627-L1663","documentation":"Thrown by Config.FindAndLoadThemePack (v9) when, after trying the theme in the Config dir, then the Startup dir, then the built-in default theme, the loaded IgTheme still reports IsValid == false AND throwIfThemeInvalid is true. IsValid is driven by the theme config file (the IgTheme config JSON) being malformed or missing required fields. The exception names the theme folder and the expected config file path so the user can locate/repair it.","triggerScenarios":"The active theme's config JSON is corrupt, truncated, or missing required keys; the theme folder was partially deleted; a hand-edited theme has invalid JSON syntax; the default theme itself is damaged (e.g. a botched install).","commonSituations":"Editing a theme config and breaking JSON; an interrupted theme download; copying a theme folder but omitting the config file; an ImageGlass upgrade that changed the theme schema and left an old theme invalid.","solutions":["Open the named themeConfigPath and validate the JSON (syntax + required fields); fix or restore from a backup.","If the active theme is unrecoverable, delete/empty the theme folder so FindAndLoadThemePack falls back to the default theme (set useFallBackTheme=true).","Reinstall/repair ImageGlass to restore the default theme pack referenced by Const.DEFAULT_THEME.","Call FindAndLoadThemePack with throwIfThemeInvalid=false to get a null instead of an exception and handle gracefully."],"exampleFix":"// before\nvar theme = Config.FindAndLoadThemePack(name, useFallBackTheme: true, throwIfThemeInvalid: true);\n\n// after: tolerate invalid, fall back to default\nvar theme = Config.FindAndLoadThemePack(name, useFallBackTheme: true, throwIfThemeInvalid: false)\n           ?? new IgTheme(App.StartUpDir(Dir.Themes, Const.DEFAULT_THEME));","handlingStrategy":"try-catch","validationCode":"// Validate the theme config JSON before loading.\nvar themeConfigPath = Path.Combine(themeFolder, \"#config.json\");\nif (!File.Exists(themeConfigPath))\n    throw new InvalidDataException($\"Missing theme config: {themeConfigPath}\");\ntry { JsonNode.Parse(File.ReadAllText(themeConfigPath)); }\ncatch (Exception) { throw new InvalidDataException($\"Malformed theme config: {themeConfigPath}\"); }","typeGuard":null,"tryCatchPattern":"try { theme = Config.FindAndLoadThemePack(name, useFallBackTheme: true, throwIfThemeInvalid: true); }\ncatch (InvalidDataException ex)\n{ theme = new IgTheme(App.StartUpDir(Dir.Themes, Const.DEFAULT_THEME)); Log.Warn(ex.Message); }","preventionTips":["Validate theme JSON (syntax + required keys) before selecting it.","Keep a known-good default theme so fallback succeeds.","Pass throwIfThemeInvalid=false in non-fatal flows and handle null."],"tags":["theme","config","json","invaliddataexception","imageglass","v9"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}