HMCL-dev/HMCL · error · IllegalArgumentException
Profile name cannot be blank
Error message
Profile name cannot be blank
What it means
OfflineAccount's constructor throws IllegalArgumentException when the given profile (character) name is null-blank. HMCL requires every offline account to carry a non-blank profile name because it is used to derive the profile UUID and identify the character in game.
Solutions
- Pass a non-blank profile name when creating the OfflineAccount (trim the user input first).
- Validate the name with StringUtils.isBlank(name) before constructing the account and show a user-facing prompt.
- If loading from storage, fall back to the account UUID string or a placeholder name instead of an empty value.
Example fix
// before
OfflineAccount acc = new OfflineAccount(downloader, name, UUID.nameUUIDFromBytes(name.getBytes()), null);
// after
String trimmed = name == null ? "" : name.trim();
if (trimmed.isEmpty()) throw new IllegalArgumentException("Please enter a character name");
OfflineAccount acc = new OfflineAccount(downloader, trimmed, UUID.nameUUIDFromBytes(trimmed.getBytes()), null); Defensive patterns
Strategy: validation
Validate before calling
if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("Character name must not be blank");
}
OfflineAccount acc = new OfflineAccount(downloader, name.trim(), profileID, skin); Try / catch
try {
account = new OfflineAccount(downloader, name, profileID, skin);
} catch (IllegalArgumentException e) {
// prompt the user to enter a valid character name
} Prevention
- Always trim and check user-supplied character names before constructing accounts.
- Validate form/input fields in the UI with a non-empty constraint.
- Sanitize names read from external config files before use.
When it happens
Trigger: Calling new OfflineAccount(downloader, "", profileID, skin) or with a whitespace-only profileName; also constructing indirectly via OfflineAccountFactory.create(accountId, name) with an empty name string.
Common situations: Programmatic account creation from scripts or launch configs where the character name field is empty; migrated/edited accounts.json where a whitespace-only name slipped in; UI bypass tools that skip name validation.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Theme-pack asset entry is empty
- accountID is missing
- acTL chunk length must be
- /assets/
- authlib-injectors.json -> urls cannot be null.
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/fc35f37b475cf389.
Report an issue: GitHub.
Appendix: source
Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java:72
private final AuthlibInjectorArtifactProvider downloader;
private final String profileName;
private final UUID profileID;
private Skin skin;
protected OfflineAccount(
AccountID accountID,
AuthlibInjectorArtifactProvider downloader,
String profileName,
UUID profileID,
Skin skin) {
super(accountID);
this.downloader = requireNonNull(downloader);
this.profileName = requireNonNull(profileName);
this.profileID = requireNonNull(profileID);
this.skin = skin;
if (StringUtils.isBlank(profileName)) {
throw new IllegalArgumentException("Profile name cannot be blank");
}
}
public AuthlibInjectorArtifactProvider getDownloader() {
return downloader;
}
@Override
public UUID getProfileID() {
return profileID;
}
@Override
public String getProfileName() {
return profileName;
}
public Skin getSkin() {View on GitHub (pinned to 24702dc5a0)