{"record":{"id":"12949c6274301393","repo":"HMCL-dev/HMCL","slug":"value-12949c","errorCode":null,"errorMessage":"${value}","messagePattern":"\\$\\{value\\}","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/util/versioning/GameVersionNumber.java","lineNumber":666,"sourceCode":"                unobfuscated = true;\n                normalized = value.substring(0, prefixLength) + \"_unobfuscated\";\n            } else {\n                prefixLength = value.length();\n                unobfuscated = false;\n                normalized = value;\n            }\n\n            if (prefixLength != 6) {\n                throw new IllegalArgumentException(value);\n            }\n\n            int year;\n            int week;\n            try {\n                year = Integer.parseInt(value, 0, 2, 10);\n                week = Integer.parseInt(value, 3, 5, 10);\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(value);\n            }\n\n            if (year >= Release.MINIMUM_YEAR_MAJOR_VERSION) {\n                throw new IllegalArgumentException(value);\n            }\n\n            char suffix = value.charAt(5);\n            if (suffix < 'a' || suffix > 'z')\n                throw new IllegalArgumentException(value);\n\n            return new LegacySnapshot(value, normalized, year, week, suffix, unobfuscated);\n        }\n\n        static int toInt(int year, int week, char suffix, boolean unobfuscated) {\n            return (year << 24) | (week << 16) | (suffix << 8) | (unobfuscated ? 1 : 0);\n        }\n\n        final int intValue;","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/util/versioning/GameVersionNumber.java#L648-L684","documentation":"`GameVersionNumber.LegacySnapshot.parse` throws `IllegalArgumentException(value)` when the 2-digit year or 2-digit week portion of a legacy snapshot id (`YYwWWx`) is not numeric — `Integer.parseInt` throws `NumberFormatException`, caught and rethrown as `IllegalArgumentException` with the original value. Note the year must also be below `MINIMUM_YEAR_MAJOR_VERSION`; years that high indicate a snapshot from the modern era that this legacy format does not cover (handled at line 669).","triggerScenarios":"Strings of the exact shape `??w??x` (6 chars, 'w' at index 2, prefix length 6) where positions 0-1 or 3-4 are non-digits, e.g. \"1.w46a\", \"18w4.a\", \"abw46a\". Also fires when the parsed year is >= the minimum year major version constant.","commonSituations":"Snapshot ids with letters accidentally in the numeric fields (\"1Aw46a\"), placeholder strings like \"YYwWWa\" from documentation, or new-style yearly versions (year >= MINIMUM_YEAR_MAJOR_VERSION) mistakenly formatted as legacy snapshots.","solutions":["Ensure characters 0-1 and 3-4 are decimal digits, e.g. validate with regex `\\d{2}w\\d{2}[a-z](_unobfuscated)?` before parsing.","Replace placeholder or corrupted fields with the actual numeric year/week values.","If the year is >= MINIMUM_YEAR_MAJOR_VERSION, the id is not a legacy snapshot — parse it as a modern Release version instead."],"exampleFix":"// before\nGameVersionNumber.parse(\"YYwWWa\"); // throws\n// after\nif (version.matches(\"\\\\d{2}w\\\\d{2}[a-z](_unobfuscated)?\")) {\n    GameVersionNumber.parse(version);\n}","handlingStrategy":"validation","validationCode":"static boolean snapshotFieldsAreNumeric(String v) {\n    return v != null && v.matches(\"\\\\d{2}w\\\\d{2}[a-z](_unobfuscated)?\");\n}\nif (!snapshotFieldsAreNumeric(id)) throw new IllegalArgumentException(\"bad snapshot id: \" + id);","typeGuard":null,"tryCatchPattern":"try {\n    GameVersionNumber.parse(id);\n} catch (IllegalArgumentException e) {\n    log.error(\"Snapshot id has non-numeric year/week fields: {}\", id);\n    // reject or prompt user for the correct id\n}","preventionTips":["Check that positions 0-1 and 3-4 are digits before parsing.","Avoid documentation placeholders like YYwWWa reaching runtime parsing.","Remember ids with a year at/above MINIMUM_YEAR_MAJOR_VERSION are modern releases, not legacy snapshots."],"tags":["java","version-parsing","minecraft-snapshot","number-format"],"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"}