HMCL-dev/HMCL · error · IllegalArgumentException

{value}

Error message

{value}

What it means

Old.parse throws IllegalArgumentException carrying the offending string when the value starts with 'r' but is not prefixed with 'rd-' (the pre-classic rd- prefix). Only 'rd-...' legacy versions starting with 'r' are recognized.

Solutions

  1. Use the exact pre-classic format 'rd-<number>' (e.g. 'rd-132211')
  2. Check for typos in the version string
  3. If the version is not a legacy pre-classic one, parse it through the appropriate path (Release/LegacySnapshot) instead of Old.parse

Example fix

// before
GameVersionNumber.asGameVersion("rd132211");
// after
GameVersionNumber.asGameVersion("rd-132211");
Defensive patterns

Strategy: validation

Validate before calling

static boolean isPreClassic(String v) {
    return v != null && v.startsWith("rd-");
}

Try / catch

try {
    GameVersionNumber v = GameVersionNumber.asGameVersion(raw);
} catch (IllegalArgumentException e) {
    log.warn("Not a valid legacy version: {}", raw);
}

Prevention

When it happens

Trigger: Passing a legacy-style version like 'r1.0', 'release-1.0', or a typo like 'rd' / 'rd_' (trailing separator missing) to GameVersionNumber parsing.

Common situations: Hand-edited version identifiers in config; version strings from third-party launchers using different legacy naming; typos when constructing pre-classic version ids.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10). Data as JSON: /api/errors/1f80a6c38d756037. Report an issue: GitHub.

Appendix: source

Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/util/versioning/GameVersionNumber.java:241

                    return gaRelease;
                }
            }
        }

        return null;
    }

    public static final class Old extends GameVersionNumber {
        static Old parse(String value) {
            if (value.isEmpty())
                throw new IllegalArgumentException("Empty old version number");

            Type type;
            int prefixLength = 1;
            switch (value.charAt(0)) {
                case 'r':
                    if (!value.startsWith("rd-")) {
                        throw new IllegalArgumentException(value);
                    }

                    type = Type.PRE_CLASSIC;
                    prefixLength = "rd-".length();
                    break;
                case 'i':
                    if (value.startsWith("inf-")) {
                        type = Type.INFDEV;
                        prefixLength = "inf-".length();
                    } else if (value.startsWith("in-")) {
                        type = Type.INDEV;
                        prefixLength = "in-".length();
                    } else {
                        throw new IllegalArgumentException(value);
                    }
                    break;
                case 'a':
                    type = Type.ALPHA;

View on GitHub (pinned to 24702dc5a0)