{"record":{"id":"b315b0ef252d9deb","repo":"HMCL-dev/HMCL","slug":"theme-field-must-be-a-string","errorCode":null,"errorMessage":"Theme field must be a string: ","messagePattern":"Theme field must be a string: ","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeAppearance.java","lineNumber":344,"sourceCode":"        JsonElement element = object.get(FIELD_WINDOW_TRANSPARENT);\n        if (element == null) {\n            return null;\n        }\n        if (!(element instanceof JsonPrimitive primitive) || !primitive.isBoolean()) {\n            LOG.warning(\"Ignored invalid theme windowTransparent: expected a boolean, got \" + element);\n            return null;\n        }\n        return primitive.getAsBoolean();\n    }\n\n    /// Reads an optional string field.\n    private static @Nullable String readString(JsonObject object, String field) {\n        JsonElement element = object.get(field);\n        if (element == null) {\n            return null;\n        }\n        if (!(element instanceof JsonPrimitive primitive) || !primitive.isString()) {\n            throw new JsonParseException(\"Theme field must be a string: \" + field);\n        }\n        return primitive.getAsString();\n    }\n\n    /// Returns a validated contrast value.\n    private static Contrast readContrastValue(double value) {\n        try {\n            return Contrast.of(value);\n        } catch (IllegalArgumentException e) {\n            throw new JsonParseException(\"Theme contrast value must be between -1 and 1: \" + value, e);\n        }\n    }\n\n    /// Adds a canonical contrast value to a JSON object.\n    private static void addContrast(JsonObject object, Contrast contrast) {\n        if (contrast.equals(Contrast.LOW)) {\n            object.addProperty(FIELD_CONTRAST, \"low\");\n        } else if (contrast.equals(Contrast.DEFAULT)) {","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeAppearance.java#L326-L362","documentation":"A generic validation helper error from ThemeAppearance.readString(): the requested JSON field exists but is not a JSON string primitive. The message names the offending field. It fires while reading string-typed theme appearance fields (e.g. color or brightness settings) whose manifest value has the wrong JSON type, such as a number or nested object.","triggerScenarios":"Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeAppearance.java:344 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the offending field in the theme manifest to a JSON string (e.g. \"#3273DC\" instead of 3273DC).","Quote numeric or boolean values that the field schema expects as strings.","Validate the theme pack JSON against the theme manifest schema before distribution."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}