{"record":{"id":"a1575fd3f655b52a","repo":"HMCL-dev/HMCL","slug":"invalid-theme-background-paint-value","errorCode":null,"errorMessage":"Invalid theme background paint: ${value}","messagePattern":"Invalid theme background paint: (.+?)","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java","lineNumber":1602,"sourceCode":"    }\n\n    /// Resolves a theme-pack built-in wallpaper ID.\n    private static String resolveBuiltinBackgroundId(@Nullable String id) throws IOException {\n        String normalizedId = StringUtils.isBlank(id)\n                ? BuiltinBackground.FALLBACK.id()\n                : id.trim().toLowerCase(Locale.ROOT);\n        if (BuiltinBackground.fromId(normalizedId) != null) {\n            return normalizedId;\n        }\n        throw new IOException(\"Theme packs cannot reference built-in wallpaper: \" + normalizedId);\n    }\n\n    /// Parses a serialized JavaFX paint value.\n    private static Paint parsePaint(String value) throws IOException {\n        try {\n            return Paint.valueOf(value);\n        } catch (IllegalArgumentException e) {\n            throw new IOException(\"Invalid theme background paint: \" + value, e);\n        }\n    }\n\n    /// Returns a non-blank string value.\n    private static String requireNonBlank(@Nullable String value, String name) throws IOException {\n        if (StringUtils.isBlank(value)) {\n            throw new IOException(\"Theme pack value is missing: \" + name);\n        }\n        return value.trim();\n    }\n\n    /// Sanitizes one path segment used for exported asset files.\n    private static String sanitizePathSegment(String value) {\n        String sanitized = value.trim().replaceAll(\"[^A-Za-z0-9._-]\", \"_\");\n        if (sanitized.isBlank()) {\n            return \"_\";\n        }\n        return sanitized;","sourceCodeStart":1584,"sourceCodeEnd":1620,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java#L1584-L1620","documentation":"Thrown by parsePaint when a serialized background paint string cannot be parsed by JavaFX's Paint.valueOf. The value must be a valid JavaFX paint expression (named color, hex, rgb(), gradient, etc.); anything else is wrapped in an IOException with the offending value.","triggerScenarios":"Parsing a theme-pack manifest whose background paint field contains a string that makes Paint.valueOf(value) throw IllegalArgumentException.","commonSituations":"Typos in color names (\"gren\" instead of \"green\"); CSS-like values JavaFX cannot parse (missing # in hex, unsupported color functions); empty or placeholder strings; values copied from web CSS that JavaFX rejects.","solutions":["Use a valid JavaFX paint value, e.g. \"#336699\", \"0x336699ff\", \"rgb(51,102,153)\", or a standard color name.","Test the value with Paint.valueOf in a scratch snippet before putting it in the manifest.","Escape correctly if the string went through JSON (quotes/backslashes must survive JSON parsing)."],"exampleFix":"// before\n\"paint\": \"rgb (51, 102, 153)\" // unparseable\n// after\n\"paint\": \"rgb(51,102,153)\"","handlingStrategy":"try-catch","validationCode":"try {\n    javafx.scene.paint.Paint.valueOf(value);\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException(\"not a valid JavaFX paint: \" + value);\n}","typeGuard":null,"tryCatchPattern":"try {\n    exportThemePack(...);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Invalid theme background paint\")) {\n        // surface e.getCause() (IllegalArgumentException) with a paint-format hint\n    }\n}","preventionTips":["Use canonical JavaFX paint strings: #rrggbb, 0xaarrggbb, rgb(r,g,b), or named colors.","Test paint values with Paint.valueOf before adding them to manifests."],"tags":["theme-pack","javafx","parse","manifest"],"backgroundTag":"invalid-argument-value","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"}