{"record":{"id":"94aedba53c68e6b5","repo":"HMCL-dev/HMCL","slug":"installed-theme-pack-does-not-contain-theme","errorCode":null,"errorMessage":"Installed theme pack does not contain theme: ","messagePattern":"Installed theme pack does not contain theme: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java","lineNumber":582,"sourceCode":"            if (replacementTheme == null) {\n                settings().selectedThemeProperty().set(BUILTIN_DEFAULT_THEME_REFERENCE);\n            }\n        }\n    }\n\n    /// Applies one theme from a loaded theme pack to current launcher settings.\n    ///\n    /// @param themePack the loaded theme pack\n    /// @param theme     the theme to apply\n    /// @throws IOException if the pack cannot be installed, referenced assets cannot be read, or settings cannot be applied\n    public static void apply(LoadedThemePack themePack, Theme theme) throws IOException {\n        Objects.requireNonNull(themePack);\n        Objects.requireNonNull(theme);\n\n        InstalledThemePack installedThemePack = install(themePack.file());\n        @Nullable Theme installedTheme = installedThemePack.manifest().findTheme(theme.id());\n        if (installedTheme == null) {\n            throw new IOException(\"Installed theme pack does not contain theme: \" + theme.id());\n        }\n        apply(installedThemePack, installedTheme);\n    }\n\n    /// Applies one theme from an installed theme pack to current launcher settings.\n    ///\n    /// @param themePack the installed theme pack\n    /// @param theme     the theme to apply\n    /// @throws IOException if referenced assets cannot be read or settings cannot be applied\n    public static void apply(InstalledThemePack themePack, Theme theme) throws IOException {\n        Objects.requireNonNull(themePack);\n        Objects.requireNonNull(theme);\n\n        apply(themePack.manifest(), theme);\n    }\n\n    /// Applies one theme to current launcher settings.\n    ///","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java#L564-L600","documentation":"The two-argument apply(ThemePack, Theme) convenience re-installs the pack file and then looks up the requested theme id in the freshly installed manifest. If findTheme(theme.id()) returns null, the installed pack does not contain that theme and this IOException is thrown with the theme id.","triggerScenarios":"Calling apply(themePack, theme) with a Theme whose id does not exist in themePack's manifest — typically because the Theme object came from a different pack or an older/cached manifest than the file being installed.","commonSituations":"Applying a theme that was removed or renamed in an updated version of the pack; mixing Theme instances across packs; caching Theme references across an uninstall/reinstall of a different pack version.","solutions":["Obtain the Theme object from installedThemePack.manifest().findTheme(id) of the same pack you are applying, rather than reusing a stale Theme instance.","Check themePack.manifest().findTheme(theme.id()) != null before calling apply.","Update stored theme references after the pack file changes, since ids may be renamed between versions."],"exampleFix":"// before\nThemePackManager.apply(packFile, staleTheme);\n// after\nInstalledThemePack installed = ThemePackManager.install(packFile);\nTheme theme = installed.manifest().findTheme(\"my-theme\");\nif (theme != null) ThemePackManager.apply(installed, theme);","handlingStrategy":"validation","validationCode":"InstalledThemePack installed = ThemePackManager.install(pack.file());\nTheme theme = installed.manifest().findTheme(themeId);\nif (theme == null) throw new IllegalArgumentException(\"theme \" + themeId + \" not in pack\");\nThemePackManager.apply(installed, theme);","typeGuard":null,"tryCatchPattern":"try {\n    ThemePackManager.apply(packFile, theme);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Installed theme pack does not contain theme\")) {\n    // refresh the Theme reference from the pack's current manifest\n    }\n}","preventionTips":["Always resolve Theme objects from the same pack's manifest via findTheme(id)","Invalidate cached Theme references whenever the pack file changes","Check theme ids against the manifest after updating a pack"],"tags":["theme-pack","apply","theme-id","lookup"],"backgroundTag":"entity-not-found","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}