{"record":{"id":"426f9789848b2c01","repo":"HMCL-dev/HMCL","slug":"unsupported-os-condition-value","errorCode":null,"errorMessage":"Unsupported os condition value: ","messagePattern":"Unsupported os condition value: ","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeCondition.java","lineNumber":199,"sourceCode":"            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\n        if (!SUPPORTED_OS_VALUES.contains(value)) {\n            throw new JsonParseException(\"Unsupported os condition value: \" + original);\n        }\n        return value;\n    }\n\n}\n","sourceCodeStart":181,"sourceCodeEnd":205,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeCondition.java#L181-L205","documentation":"normalizeOperatingSystemValue maps OS condition values to a known set and verifies membership in SUPPORTED_OS_VALUES. An OS value outside the supported set (after normalization) throws this JsonParseException.","triggerScenarios":"ThemeCondition.fromJson reading {\"os\": [\"android\"]} or {\"os\": \"win32\"} — a value not among the supported tokens (e.g. windows/linux/macos/freebsd/unknown and their aliases).","commonSituations":"Theme authors using raw os.name values (\"win32\", \"Windows 11\") instead of the launcher's tokens; ported themes from other tools; new OS names not yet in the launcher's supported list.","solutions":["Replace the OS value with a supported token such as \"windows\", \"linux\", \"macos\", \"freebsd\", or \"unknown\".","Normalize aliases before writing the theme (e.g. map \"win32\"/\"win\" -> \"windows\").","Check the ThemeCondition source for the exact SUPPORTED_OS_VALUES set and match it.","Catch JsonParseException and display the supported OS values to the theme author."],"exampleFix":"// before (theme.json)\n// \"os\": [\"win32\"]\n// after\n\"os\": [\"windows\"]","handlingStrategy":"validation","validationCode":"java.util.Set<String> supported = java.util.Set.of(\"windows\",\"linux\",\"macos\",\"freebsd\",\"unknown\");\nboolean ok = supported.contains(os.trim().toLowerCase(java.util.Locale.ROOT));","typeGuard":"static boolean isSupportedOsValue(String v) {\n    String n = v == null ? \"\" : v.trim().toLowerCase(java.util.Locale.ROOT);\n    return java.util.Set.of(\"windows\",\"linux\",\"macos\",\"freebsd\",\"unknown\").contains(n);\n}","tryCatchPattern":"try {\n    ThemeCondition c = ThemeCondition.fromJson(element);\n} catch (JsonParseException e) {\n    LOG.warning(\"Unsupported OS condition value: \" + e.getMessage());\n}","preventionTips":["Use the launcher's OS tokens, not raw os.name strings","Map aliases (win32 -> windows, osx -> macos) before writing themes","Check SUPPORTED_OS_VALUES in ThemeCondition for the authoritative list","Validate OS values at theme-authoring time"],"tags":["json","theme","condition","os","enum-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-16T04:17:20.429Z"}