{"record":{"id":"89b86153a573a939","repo":"HMCL-dev/HMCL","slug":"user-id-cannot-be-empty","errorCode":null,"errorMessage":"User id cannot be empty.","messagePattern":"User id cannot be empty\\.","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/User.java","lineNumber":44,"sourceCode":"import org.jackhuang.hmcl.util.StringUtils;\nimport org.jackhuang.hmcl.util.gson.Validation;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n *\n * @author huang\n */\n@Immutable\npublic record User(String id, @JsonAdapter(PropertyMapSerializer.class) @Nullable Map<String, String> properties) implements Validation {\n\n    public User(String id) {\n        this(id, null);\n    }\n\n    @Override\n    public void validate() throws JsonParseException {\n        if (StringUtils.isBlank(id))\n            throw new JsonParseException(\"User id cannot be empty.\");\n    }\n}\n","sourceCodeStart":26,"sourceCodeEnd":47,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/User.java#L26-L47","documentation":"User.validate() throws JsonParseException when the deserialized yggdrasil user record has a blank id. The id field (unique user identifier from the auth server) is mandatory, so its absence means the authentication response is malformed.","triggerScenarios":"Parsing an authentication/refresh response whose JSON lacks \"id\" or has it empty, when constructing the User object from server data (e.g. User selectedProfile/availableProfiles deserialization).","commonSituations":"Faulty third-party auth servers omitting the user id; corrupted cached yggdrasil user JSON in the launcher data directory; proxies rewriting responses.","solutions":["Ensure the auth server returns a non-blank \"id\" field in its user JSON.","Delete the cached/stored user JSON and re-authenticate to rebuild it.","Switch to a working authentication server (official Mojang or a healthy authlib-injector instance)."],"exampleFix":"// before (server response)\n{\"properties\":[]}\n// after\n{\"id\":\"8d3d7ad4...\",\"properties\":[]}","handlingStrategy":"validation","validationCode":"JsonObject user = JsonParser.parseString(responseText).getAsJsonObject();\nif (!user.has(\"id\") || user.get(\"id\").getAsString().isBlank()) {\n    throw new JsonParseException(\"Auth server response missing user id\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    // yggdrasil login flow that deserializes User\n} catch (JsonParseException e) {\n    // flag the auth server as broken and prompt re-authentication\n}","preventionTips":["Prefer well-maintained auth servers; test responses before bulk logins.","Re-authenticate rather than reusing cached user JSON when in doubt.","Monitor auth server health before releasing launcher updates."],"tags":["json","validation","yggdrasil"],"backgroundTag":"schema-validation-failed","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"}