HMCL-dev/HMCL · error · JsonParseException

User id cannot be empty.

Error message

User id cannot be empty.

What it means

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.

Solutions

  1. Ensure the auth server returns a non-blank "id" field in its user JSON.
  2. Delete the cached/stored user JSON and re-authenticate to rebuild it.
  3. Switch to a working authentication server (official Mojang or a healthy authlib-injector instance).

Example fix

// before (server response)
{"properties":[]}
// after
{"id":"8d3d7ad4...","properties":[]}
Defensive patterns

Strategy: validation

Validate before calling

JsonObject user = JsonParser.parseString(responseText).getAsJsonObject();
if (!user.has("id") || user.get("id").getAsString().isBlank()) {
    throw new JsonParseException("Auth server response missing user id");
}

Try / catch

try {
    // yggdrasil login flow that deserializes User
} catch (JsonParseException e) {
    // flag the auth server as broken and prompt re-authentication
}

Prevention

When it happens

Trigger: 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).

Common situations: Faulty third-party auth servers omitting the user id; corrupted cached yggdrasil user JSON in the launcher data directory; proxies rewriting responses.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10). Data as JSON: /api/errors/89b86153a573a939. Report an issue: GitHub.

Appendix: source

Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/User.java:44

import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.gson.Validation;
import org.jetbrains.annotations.Nullable;

/**
 *
 * @author huang
 */
@Immutable
public record User(String id, @JsonAdapter(PropertyMapSerializer.class) @Nullable Map<String, String> properties) implements Validation {

    public User(String id) {
        this(id, null);
    }

    @Override
    public void validate() throws JsonParseException {
        if (StringUtils.isBlank(id))
            throw new JsonParseException("User id cannot be empty.");
    }
}

View on GitHub (pinned to 24702dc5a0)