{"record":{"id":"19102031dbc45976","repo":"HMCL-dev/HMCL","slug":"empty-theme-condition-context-value-name","errorCode":null,"errorMessage":"Empty theme condition context value: ${name}","messagePattern":"Empty theme condition context value: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeResolveContext.java","lineNumber":90,"sourceCode":"    }\n\n    /// Returns the normalized name for an operating system.\n    ///\n    /// @param operatingSystem the operating system to normalize\n    /// @return the normalized operating system name\n    static String normalizeOperatingSystem(OperatingSystem operatingSystem) {\n        Objects.requireNonNull(operatingSystem);\n\n        return operatingSystem == OperatingSystem.UNKNOWN ? \"unknown\" : operatingSystem.getCheckedName();\n    }\n\n    /// Normalizes one condition context token.\n    private static String normalizeToken(String value, String name) {\n        Objects.requireNonNull(value, name);\n\n        String normalized = value.trim().toLowerCase(Locale.ROOT);\n        if (normalized.isEmpty()) {\n            throw new IllegalArgumentException(\"Empty theme condition context value: \" + name);\n        }\n        return normalized;\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":95,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeResolveContext.java#L72-L95","documentation":"ThemeResolveContext.normalizeToken lowercases and trims a condition context token (e.g. language, platform values used in theme conditional expressions); if the normalized value is empty it throws IllegalArgumentException \"Empty theme condition context value: <name>\". Condition matching requires non-empty tokens so rules always evaluate against concrete values.","triggerScenarios":"Building a ThemeResolveContext with an empty or whitespace-only value for a named context key; a system property or environment lookup that returned \"\" for language/OS tokens.","commonSituations":"Environment variables or settings that are defined but empty; refactored code passing an optional value straight through without a default; localized system reports with blank locale fields.","solutions":["Supply a concrete non-blank value for the named context key when constructing ThemeResolveContext.","Add a default (e.g. \"unknown\" or \"en\") when the underlying setting may be empty.","Check where the value originates (system property/env) and fix the source that yields the blank string."],"exampleFix":"// before\nctx = new ThemeResolveContext(lang, \"\")\n// after\nctx = new ThemeResolveContext(lang.isBlank() ? \"en\" : lang, osName)","handlingStrategy":"validation","validationCode":"String safe = value == null ? null : value.trim().toLowerCase(Locale.ROOT); boolean ok = safe != null && !safe.isEmpty();","typeGuard":null,"tryCatchPattern":"try { ctx = new ThemeResolveContext(values); } catch (IllegalArgumentException e) { ctx = defaultContext(); }","preventionTips":["Default empty env/system values to a known token like \"unknown\"","Normalize and check tokens at the call site","Never pass optional lookups straight into context construction"],"tags":["theme-pack","context","validation"],"backgroundTag":"empty-required-field","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"}