d2phap/ImageGlass · error · InvalidDataException
Unable to load '{themeFolderName}' theme pack. Please make s
Error message
Unable to load '{themeFolderName}' theme pack. Please make sure '{themeConfigPath}' file is valid. What it means
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.
Source
Thrown at v9/Components/ImageGlass.Settings/Config.cs:1645
// cannot find theme, use fall back theme
if (!th.IsValid && useFallBackTheme)
{
th.Dispose();
th = null;
// load default theme
th = new(App.StartUpDir(Dir.Themes, Const.DEFAULT_THEME));
}
}
if (!th.IsValid && throwIfThemeInvalid)
{
th.Dispose();
th = null;
throw new InvalidDataException($"Unable to load '{themeFolderName}' theme pack. " +
$"Please make sure '{themeConfigPath}' file is valid.");
}
return th;
}
/// <summary>
/// Triggers <see cref="RequestUpdatingTheme"/> event.
/// </summary>
public static void TriggerRequestUpdatingTheme()
{
RequestUpdatingTheme?.Invoke(new RequestUpdatingThemeEventArgs(Config.Theme));
}
/// <summary>
/// Triggers <see cref="RequestUpdatingLanguage"/> event.View on GitHub (pinned to 4a3c4fecef)
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.
Example fix
// before
var theme = Config.FindAndLoadThemePack(name, useFallBackTheme: true, throwIfThemeInvalid: true);
// after: tolerate invalid, fall back to default
var theme = Config.FindAndLoadThemePack(name, useFallBackTheme: true, throwIfThemeInvalid: false)
?? new IgTheme(App.StartUpDir(Dir.Themes, Const.DEFAULT_THEME)); Defensive patterns
Strategy: try-catch
Validate before calling
// Validate the theme config JSON before loading.
var themeConfigPath = Path.Combine(themeFolder, "#config.json");
if (!File.Exists(themeConfigPath))
throw new InvalidDataException($"Missing theme config: {themeConfigPath}");
try { JsonNode.Parse(File.ReadAllText(themeConfigPath)); }
catch (Exception) { throw new InvalidDataException($"Malformed theme config: {themeConfigPath}"); } Try / catch
try { theme = Config.FindAndLoadThemePack(name, useFallBackTheme: true, throwIfThemeInvalid: true); }
catch (InvalidDataException ex)
{ theme = new IgTheme(App.StartUpDir(Dir.Themes, Const.DEFAULT_THEME)); Log.Warn(ex.Message); } Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- IGE: Could not parse merged config.
- IGE: Unable to load '{themeFolderName}' theme pack. Please m
- The base64 content is invalid.
- IGE_001
- IGE_002
AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13).
Data as JSON: /api/errors/1a4e926b2566d6b4.
Report an issue: GitHub.