HMCL-dev/HMCL · error · IllegalArgumentException
accountID is missing
Error message
accountID is missing
What it means
Account.readAccountID is a static helper that deserializes an account's persisted ID from its JsonObject storage. If the storage object lacks the ACCOUNT_ID property (null), it throws IllegalArgumentException because an account record without an ID cannot be reconstructed. This indicates corrupt or hand-edited persistence data.
Solutions
- Ensure the stored JsonObject contains the account ID property before parsing
- Re-create the account (re-login) if its stored data is corrupt or incomplete
- When migrating storage formats, copy/transform the ID field into the expected property
Example fix
// before
AccountID id = Account.readAccountID(storage); // storage lacks id
// after
if (storage.has(Account.PROPERTY_ACCOUNT_ID)) {
AccountID id = Account.readAccountID(storage);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (storage == null || !storage.has(Account.PROPERTY_ACCOUNT_ID)) {
throw new IllegalArgumentException("Account storage lacks id; re-login required");
} Type guard
boolean hasId = storage != null && storage.has(Account.PROPERTY_ACCOUNT_ID); AccountID id = hasId ? Account.readAccountID(storage) : null;
Try / catch
try {
AccountID id = Account.readAccountID(storage);
} catch (IllegalArgumentException e) {
log.warn("Corrupt account entry, skipping/re-login: {}", e.getMessage());
} Prevention
- Never hand-edit accounts.json
- Validate storage schema after migrations
- Re-login accounts whose stored fields are missing
When it happens
Trigger: Calling Account.readAccountID(JsonObject) with a storage object missing the account ID property, e.g. deserializing accounts.json entries written by an older version or edited by hand.
Common situations: Manually editing or migrating accounts.json; upgrading HMCL across versions where the storage schema changed; truncated/corrupt storage files.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- storage does not have API root.
- storage does not have loginName
- GameRemoteVersions.versions cannot be null
- IdDownloadInfo id can not be null
- LoggingInfo.argument is empty.
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/cf3352003a9eebe7.
Report an issue: GitHub.
Appendix: source
Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/auth/Account.java:163
return null;
}
try {
return AccountID.parse(accountID);
} catch (IllegalArgumentException e) {
return null;
}
}
/// Reads an account ID from serialized account storage.
///
/// @param storage the account storage object
/// @return the parsed account ID
/// @throws IllegalArgumentException if the storage has no valid account ID
public static AccountID readAccountID(JsonObject storage) {
@Nullable String accountID = JsonUtils.getString(storage, PROPERTY_ACCOUNT_ID);
if (accountID == null) {
throw new IllegalArgumentException("accountID is missing");
}
return AccountID.parse(accountID);
}
private final ObservableHelper helper = new ObservableHelper(this);
@Override
public void addListener(InvalidationListener listener) {
helper.addListener(listener);
}
@Override
public void removeListener(InvalidationListener listener) {
helper.removeListener(listener);
}
/**View on GitHub (pinned to 24702dc5a0)