{"record":{"id":"20e5620549076630","repo":"HMCL-dev/HMCL","slug":"messageprefix-value","errorCode":null,"errorMessage":"${messagePrefix}${value}","messagePattern":"\\$\\{messagePrefix\\}\\$\\{value\\}","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManifest.java","lineNumber":258,"sourceCode":"        }\n        return trimmed;\n    }\n\n    /// Returns a package ID matching the theme-pack ID format.\n    static String requirePackageId(String value) {\n        return requireId(value, \"id\", \"Theme-pack manifest ID must follow package ID format: \");\n    }\n\n    /// Returns a theme ID matching the theme-pack ID format.\n    static String requireThemeId(String value) {\n        return requireId(value, \"theme id\", \"Theme ID must follow package ID format: \");\n    }\n\n    /// Returns an ID matching the theme-pack ID format.\n    private static String requireId(String value, String field, String messagePrefix) {\n        String id = requireNonBlank(value, field);\n        if (!PACKAGE_ID_PATTERN.matcher(id).matches()) {\n            throw new IllegalArgumentException(messagePrefix + value);\n        }\n        return id;\n    }\n\n    static final class Adapter implements JsonSerializer<@Nullable ThemePackManifest>,\n            JsonDeserializer<@Nullable ThemePackManifest> {\n\n        @Override\n        public @Nullable ThemePackManifest deserialize(\n                @Nullable JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {\n            if (json == null || json instanceof JsonNull) {\n                return null;\n            }\n\n            if (!(json instanceof JsonObject object)) {\n                throw new JsonParseException(\"Theme-pack manifest is not a JsonObject\");\n            }\n","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManifest.java#L240-L276","documentation":"requireId validates that an id/version-like manifest field both is non-blank and matches PACKAGE_ID_PATTERN; when the pattern fails it throws IllegalArgumentException with messagePrefix plus the offending value. messagePrefix distinguishes package IDs from theme IDs (e.g. \"Invalid theme-pack id: \").","triggerScenarios":"Calling requirePackageId or requireThemeId with a value containing characters outside the allowed ID format (spaces, uppercase, symbols, wrong length); this is invoked during ThemePackManifest parsing of the \"id\" field or theme ids.","commonSituations":"Authors naming packs with display names instead of identifiers (\"My Cool Theme!\"); ids with uppercase letters or dots when the pattern expects kebab/lowercase segments; leftover template placeholders.","solutions":["Rewrite the offending id to match PACKAGE_ID_PATTERN (typically lowercase letters, digits, and hyphens, e.g. \"my-cool-theme\").","Check the message text after the prefix to see the exact invalid value, then fix that field in theme_pack.json.","Keep human-readable names in \"name\" and machine identifiers in \"id\"."],"exampleFix":"// before\n\"id\": \"My Cool Theme!\"\n// after\n\"id\": \"my-cool-theme\"","handlingStrategy":"validation","validationCode":"boolean validId = id != null && id.matches(\"[a-z0-9]+(-[a-z0-9]+)*\");","typeGuard":null,"tryCatchPattern":"try { String id = ThemePackManifest.requirePackageId(raw); } catch (IllegalArgumentException e) { log.warn(\"Bad id: \" + raw); }","preventionTips":["Keep ids lowercase kebab-case; reserve display text for \"name\"","Run the same PACKAGE_ID_PATTERN check in your pack build script","Never copy display names into the id field"],"tags":["theme-pack","identifier","validation"],"backgroundTag":"invalid-identifier-format","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"}