{"record":{"id":"2b98b2551d201f14","repo":"HMCL-dev/HMCL","slug":"unsupported-brightness-condition-value","errorCode":null,"errorMessage":"Unsupported brightness condition value: ","messagePattern":"Unsupported brightness condition value: ","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeCondition.java","lineNumber":179,"sourceCode":"        }\n        return normalized;\n    }\n\n    /// Normalizes and validates one condition value.\n    private static String normalizeValue(String key, String value) {\n        Objects.requireNonNull(key);\n        Objects.requireNonNull(value);\n\n        String trimmed = value.trim();\n        if (trimmed.isEmpty()) {\n            throw new JsonParseException(\"Empty theme condition value for \" + key);\n        }\n        String normalized = trimmed.toLowerCase(Locale.ROOT);\n\n        return switch (key) {\n            case KEY_BRIGHTNESS -> switch (normalized) {\n                    case \"light\", \"dark\" -> normalized;\n                    default -> throw new JsonParseException(\"Unsupported brightness condition value: \" + value);\n                };\n            case KEY_OS -> normalizeOperatingSystemValue(normalized, value);\n            case KEY_LANGUAGE -> normalized;\n            default -> trimmed;\n        };\n    }\n\n    /// Normalizes an operating system condition value.\n    private static String normalizeOperatingSystemValue(String normalized, String original) {\n        String value = switch (normalized) {\n            case \"win\", \"windows\" -> \"windows\";\n            case \"mac\", \"macos\", \"osx\" -> \"macos\";\n            case \"linux\" -> \"linux\";\n            case \"freebsd\" -> \"freebsd\";\n            case \"unknown\", \"universal\" -> \"unknown\";\n            default -> normalized;\n        };\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeCondition.java#L161-L197","documentation":"For the \"brightness\" condition key, normalizeValue only accepts \"light\" or \"dark\" (case-insensitive). Any other value throws this JsonParseException, keeping brightness conditions limited to the two supported appearance modes.","triggerScenarios":"ThemeCondition.fromJson reading {\"brightness\": [\"system\"]} or {\"brightness\": \"auto\"} — a value that is not light/dark after lowercasing.","commonSituations":"Theme authors guessing at brightness vocabulary (\"auto\", \"system\", \"high-contrast\"); copy-paste from other theming systems; typos like \"darke\".","solutions":["Use only \"light\" or \"dark\" for the brightness condition, e.g. \"brightness\": [\"dark\"].","Move non-brightness concepts (e.g. system-default) to a supported condition key or drop them.","Normalize author input to light/dark before writing the theme file.","Catch JsonParseException around fromJson and list the allowed values (light, dark) in the error shown to the user."],"exampleFix":"// before (theme.json)\n// \"brightness\": [\"auto\"]\n// after\n\"brightness\": [\"light\", \"dark\"]","handlingStrategy":"validation","validationCode":"boolean ok = \"light\".equalsIgnoreCase(v) || \"dark\".equalsIgnoreCase(v);","typeGuard":"static boolean isBrightnessValue(String v) {\n    return \"light\".equalsIgnoreCase(v) || \"dark\".equalsIgnoreCase(v);\n}","tryCatchPattern":"try {\n    ThemeCondition c = ThemeCondition.fromJson(element);\n} catch (JsonParseException e) {\n    LOG.warning(\"Bad brightness value (use light/dark): \" + e.getMessage());\n}","preventionTips":["Only use \"light\" or \"dark\" for brightness conditions","Do not invent values like auto/system — they are unsupported","Validate brightness values against a whitelist when generating themes","Document allowed brightness values for theme authors"],"tags":["json","theme","condition","enum-value"],"backgroundTag":"unsupported-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"}