{"record":{"id":"049f7089d91ad49c","repo":"HMCL-dev/HMCL","slug":"profileid-is-missing-049f70","errorCode":null,"errorMessage":"profileID is missing","messagePattern":"profileID is missing","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilSession.java","lineNumber":90,"sourceCode":"    public List<GameProfile> getAvailableProfiles() {\n        return availableProfiles;\n    }\n\n    public Map<String, String> getUserProperties() {\n        return userProperties;\n    }\n\n    public boolean hasProfileName() {\n        return selectedProfile != null && StringUtils.isNotBlank(selectedProfile.getName());\n    }\n\n    public static YggdrasilSession fromStorage(JsonObject metadata, JsonObject privateData) {\n        Objects.requireNonNull(metadata);\n        Objects.requireNonNull(privateData);\n\n        String profileIDText = JsonUtils.getString(metadata, \"profileID\");\n        if (profileIDText == null) {\n            throw new IllegalArgumentException(\"profileID is missing\");\n        }\n        UUID profileID = UUIDs.parse(profileIDText);\n        String profileName = JsonUtils.getString(privateData, \"profileName\", \"\");\n        String clientToken = requireStorageString(privateData, \"clientToken\");\n        String accessToken = requireStorageString(privateData, \"accessToken\");\n        @Nullable Map<String, String> userProperties = privateData.get(\"userProperties\") instanceof JsonObject userPropertiesObject\n                ? GSON_PROPERTIES.fromJson(userPropertiesObject, JsonUtils.mapTypeOf(String.class, String.class))\n                : null;\n        return new YggdrasilSession(clientToken, accessToken, new GameProfile(profileID, profileName), null, userProperties);\n    }\n\n    public void writePrivateData(JsonObject privateData) {\n        if (selectedProfile == null)\n            throw new IllegalStateException(\"No character is selected\");\n\n        privateData.addProperty(\"clientToken\", clientToken);\n        privateData.addProperty(\"accessToken\", accessToken);\n        privateData.addProperty(\"profileName\", selectedProfile.getName());","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilSession.java#L72-L108","documentation":"Thrown by YggdrasilSession.fromStorage when the stored account metadata JSON lacks the 'profileID' key. The library requires a profile ID to reconstruct the session's game profile; without it the account record is considered corrupt/incomplete.","triggerScenarios":"Calling YggdrasilSession.fromStorage with a metadata JsonObject that has no 'profileID' string entry (e.g. an account entry written by an older HMCL version or hand-edited accounts.json).","commonSituations":"Upgrading HMCL with legacy account storage, manually editing accounts.json and deleting profileID, or third-party tools writing partial account metadata.","solutions":["Re-add the 'profileID' key to the account metadata JSON with the UUID string of the Minecraft profile","Delete the corrupt account entry and re-authenticate/login to recreate a complete storage record","Restore accounts.json from a backup taken before the corruption"],"exampleFix":"// before\nJsonObject metadata = entry; // missing profileID\nYggdrasilSession.fromStorage(metadata, privateData);\n// after\nif (JsonUtils.getString(metadata, \"profileID\") == null) {\n    metadata = reauthenticateToRebuildMetadata();\n}\nYggdrasilSession.fromStorage(metadata, privateData);","handlingStrategy":"validation","validationCode":"if (metadata == null || JsonUtils.getString(metadata, \"profileID\") == null)\n    throw new IllegalArgumentException(\"Account metadata lacks profileID; re-authenticate this account\");","typeGuard":"static boolean hasProfileID(JsonObject metadata) {\n    return metadata != null && metadata.get(\"profileID\") instanceof JsonPrimitive p && p.isString();\n}","tryCatchPattern":"try {\n    session = YggdrasilSession.fromStorage(metadata, privateData);\n} catch (IllegalArgumentException e) {\n    LOG.warning(\"Corrupt account entry: \" + e.getMessage());\n    session = reauthenticateAccount();\n}","preventionTips":["Never hand-edit accounts.json; use the app's account management","Back up account storage before upgrades","Validate stored JSON fields after version migrations"],"tags":["java","minecraft","account-storage","json"],"backgroundTag":"missing-required-config-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"}