{"record":{"id":"fc35f37b475cf389","repo":"HMCL-dev/HMCL","slug":"profile-name-cannot-be-blank","errorCode":null,"errorMessage":"Profile name cannot be blank","messagePattern":"Profile name cannot be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java","lineNumber":72,"sourceCode":"    private final AuthlibInjectorArtifactProvider downloader;\n    private final String profileName;\n    private final UUID profileID;\n    private Skin skin;\n\n    protected OfflineAccount(\n            AccountID accountID,\n            AuthlibInjectorArtifactProvider downloader,\n            String profileName,\n            UUID profileID,\n            Skin skin) {\n        super(accountID);\n        this.downloader = requireNonNull(downloader);\n        this.profileName = requireNonNull(profileName);\n        this.profileID = requireNonNull(profileID);\n        this.skin = skin;\n\n        if (StringUtils.isBlank(profileName)) {\n            throw new IllegalArgumentException(\"Profile name cannot be blank\");\n        }\n    }\n\n    public AuthlibInjectorArtifactProvider getDownloader() {\n        return downloader;\n    }\n\n    @Override\n    public UUID getProfileID() {\n        return profileID;\n    }\n\n    @Override\n    public String getProfileName() {\n        return profileName;\n    }\n\n    public Skin getSkin() {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nOfflineAccount acc = new OfflineAccount(downloader, name, UUID.nameUUIDFromBytes(name.getBytes()), null);\n// after\nString trimmed = name == null ? \"\" : name.trim();\nif (trimmed.isEmpty()) throw new IllegalArgumentException(\"Please enter a character name\");\nOfflineAccount acc = new OfflineAccount(downloader, trimmed, UUID.nameUUIDFromBytes(trimmed.getBytes()), null);","handlingStrategy":"validation","validationCode":"if (name == null || name.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"Character name must not be blank\");\n}\nOfflineAccount acc = new OfflineAccount(downloader, name.trim(), profileID, skin);","typeGuard":null,"tryCatchPattern":"try {\n    account = new OfflineAccount(downloader, name, profileID, skin);\n} catch (IllegalArgumentException e) {\n    // prompt the user to enter a valid character name\n}","preventionTips":["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."],"tags":["validation","arguments","offline-account"],"backgroundTag":"empty-required-field","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}