{"record":{"id":"a79c0e098bb009e4","repo":"HMCL-dev/HMCL","slug":"invalid-theme-color","errorCode":null,"errorMessage":"Invalid theme color: ","messagePattern":"Invalid theme color: ","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeColorSource.java","lineNumber":68,"sourceCode":"    static ThemeColorSource wallpaper() {\n        return new Wallpaper();\n    }\n\n    /// Parses a color source from a manifest JSON value.\n    ///\n    /// @param element the JSON value\n    /// @return the parsed color source\n    /// @throws JsonParseException if the color source is malformed\n    static ThemeColorSource fromJson(JsonElement element) throws JsonParseException {\n        Objects.requireNonNull(element);\n        if (element instanceof JsonPrimitive primitive && primitive.isString()) {\n            String value = primitive.getAsString();\n            if (\"default\".equals(value.trim().replace('-', '_').toLowerCase(Locale.ROOT))) {\n                return DEFAULT;\n            }\n            @Nullable ThemeColor color = ThemeColor.of(value);\n            if (color == null) {\n                throw new JsonParseException(\"Invalid theme color: \" + value);\n            }\n            return custom(color);\n        }\n        if (!(element instanceof JsonObject object)) {\n            throw new JsonParseException(\"Theme color must be a string or object\");\n        }\n\n        JsonElement sourceElement = object.get(FIELD_SOURCE);\n        if (sourceElement == null) {\n            throw new JsonParseException(\"Theme color source is missing required field: \" + FIELD_SOURCE);\n        }\n        if (!(sourceElement instanceof JsonPrimitive sourcePrimitive) || !sourcePrimitive.isString()) {\n            throw new JsonParseException(\"Theme color source field must be a string: \" + FIELD_SOURCE);\n        }\n        String source = sourcePrimitive.getAsString();\n        String normalized = source.trim().replace('-', '_').toUpperCase(Locale.ROOT);\n        if (\"DEFAULT\".equals(normalized)) {\n            return DEFAULT;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeColorSource.java#L50-L86","documentation":"ThemeColorSource.fromJson throws this JsonParseException when the theme color is given as a string (not \"default\") that ThemeColor.of cannot resolve to a known ThemeColor enum constant. The manifest's color name is not one of the launcher's supported named colors, so the seed color cannot be determined.","triggerScenarios":"fromJson on a JSON string such as \"blurple\", \"teal-500\", or a misspelled name like \"deep_purpple\" that matches no ThemeColor constant (normalization is trim + '-'->'_' + lowercase for the default check; the color lookup itself is case/name sensitive via ThemeColor.of).","commonSituations":"Theme authors inventing custom color names, copy-pasting hex codes (\"#3b82f6\") where an enum name is required, or names from a different HMCL version's color list.","solutions":["Replace the string with a valid ThemeColor enum name exactly as defined in the HMCL version in use","Use \"default\" if the launcher's built-in seed color is acceptable","Check available names via ThemeColor.values()/name() and fix spelling/casing"],"exampleFix":"// before\n\"color\": \"blurple\"\n// after\n\"color\": \"default\"","handlingStrategy":"validation","validationCode":"String v = element.getAsString();\nif (!\"default\".equalsIgnoreCase(v) && ThemeColor.of(v) == null) throw new IllegalArgumentException(\"Unknown theme color: \" + v);","typeGuard":"boolean isKnownThemeColor(String s) {\n    return \"default\".equalsIgnoreCase(s) || ThemeColor.of(s) != null;\n}","tryCatchPattern":"try { ThemeColorSource.fromJson(el); } catch (JsonParseException e) { LOG.warning(\"Bad color, falling back: \" + e.getMessage()); src = ThemeColorSource.DEFAULT; }","preventionTips":["Only use color names that exist as ThemeColor constants in your HMCL version","Never put hex codes where an enum name is expected","Copy names from ThemeColor.values() output, not from memory"],"tags":["json","enum","theme-config","invalid-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}