{"record":{"id":"9b4f5ff993903eb2","repo":"HMCL-dev/HMCL","slug":"profile-name-is-missing","errorCode":null,"errorMessage":"Profile name is missing","messagePattern":"Profile name is missing","errorType":"exception","errorClass":"ServerResponseMalformedException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/microsoft/MicrosoftAccount.java","lineNumber":89,"sourceCode":"\n    @Override\n    public UUID getProfileID() {\n        return session.profile().id();\n    }\n\n    @Override\n    public AuthInfo logIn() throws AuthenticationException {\n        if (!authenticated || !session.hasProfileName() || System.currentTimeMillis() > session.notAfter()) {\n            if (session.hasProfileName()\n                    && service.validate(session.notAfter(), session.tokenType(), session.accessToken())) {\n                authenticated = true;\n            } else {\n                MicrosoftSession acquiredSession = service.refresh(session);\n                if (!Objects.equals(acquiredSession.profile().id(), session.profile().id())) {\n                    throw new ServerResponseMalformedException(\"Selected profile changed\");\n                }\n                if (!acquiredSession.hasProfileName()) {\n                    throw new ServerResponseMalformedException(\"Profile name is missing\");\n                }\n\n                session = acquiredSession;\n\n                authenticated = true;\n                invalidate();\n            }\n        }\n\n        return session.toAuthInfo();\n    }\n\n    @Override\n    public AuthInfo logInWhenCredentialsExpired() throws AuthenticationException {\n        MicrosoftSession acquiredSession = service.authenticate(OAuth.GrantFlow.DEVICE);\n        if (!Objects.equals(profileID, acquiredSession.profile().id())) {\n            throw new WrongAccountException(profileID, acquiredSession.profile().id());\n        }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/microsoft/MicrosoftAccount.java#L71-L107","documentation":"After a successful session refresh, HMCL requires the MicrosoftSession to carry a profile name (the Minecraft username). If acquiredSession.hasProfileName() is false, ServerResponseMalformedException('Profile name is missing') is thrown since a session without a username cannot produce valid AuthInfo.","triggerScenarios":"The Microsoft/minecraftservices profile endpoint returns a session with an id but no name — typically because the account does not own the game or has no Minecraft profile yet, while the refresh path still produced a session object.","commonSituations":"Account owns Minecraft: Java Edition but the profile was never created (never launched the game); Xbox Game Pass entitlement not yet provisioned; account is a demo/unmigrated state; the microsoftservices profile API returned partial data during an outage.","solutions":["Launch Minecraft once with the official launcher (or create the profile at minecraft.net) so the account has a username, then retry login","Check that the account actually owns Java Edition / has an active Game Pass subscription","Retry later if Mojang/microsoftservices is having an outage returning partial profile data","Re-add the account in HMCL to force a full fresh login rather than refresh"],"exampleFix":"// before: assuming any authenticated account has a profile\naccount.logIn();\n// after: check entitlements/profile existence first\nif (!account.getService().getProfileType().equals(AccountProfileType.MOJANG)\n        || !hasMinecraftProfile(account)) {\n    throw new UnsupportedOperationException(\"This Microsoft account has no Minecraft profile; buy the game or create the profile first.\");\n}\naccount.logIn();","handlingStrategy":"try-catch","validationCode":"// check profile/entitlement existence before login\n// GET https://api.minecraftservices.com/minecraft/profile with a fresh token; a 404 means no profile name exists yet","typeGuard":null,"tryCatchPattern":"try {\n    account.logIn();\n} catch (ServerResponseMalformedException e) {\n    if (\"Profile name is missing\".equals(e.getMessage())) {\n        // account has no Minecraft profile; instruct user to create it\n    } else throw e;\n}","preventionTips":["Ensure the account owns Java Edition and has launched the game at least once","Check for Mojang outages before bulk logins","Re-authenticate fully rather than relying on refresh for accounts in unusual states"],"tags":["authentication","microsoft","profile","missing-data"],"backgroundTag":"unexpected-api-response-shape","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"}