{"record":{"id":"cf3352003a9eebe7","repo":"HMCL-dev/HMCL","slug":"accountid-is-missing","errorCode":null,"errorMessage":"accountID is missing","messagePattern":"accountID is missing","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/Account.java","lineNumber":163,"sourceCode":"            return null;\n        }\n\n        try {\n            return AccountID.parse(accountID);\n        } catch (IllegalArgumentException e) {\n            return null;\n        }\n    }\n\n    /// Reads an account ID from serialized account storage.\n    ///\n    /// @param storage the account storage object\n    /// @return the parsed account ID\n    /// @throws IllegalArgumentException if the storage has no valid account ID\n    public static AccountID readAccountID(JsonObject storage) {\n        @Nullable String accountID = JsonUtils.getString(storage, PROPERTY_ACCOUNT_ID);\n        if (accountID == null) {\n            throw new IllegalArgumentException(\"accountID is missing\");\n        }\n\n        return AccountID.parse(accountID);\n    }\n\n    private final ObservableHelper helper = new ObservableHelper(this);\n\n    @Override\n    public void addListener(InvalidationListener listener) {\n        helper.addListener(listener);\n    }\n\n    @Override\n    public void removeListener(InvalidationListener listener) {\n        helper.removeListener(listener);\n    }\n\n    /**","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/Account.java#L145-L181","documentation":"Account.readAccountID is a static helper that deserializes an account's persisted ID from its JsonObject storage. If the storage object lacks the ACCOUNT_ID property (null), it throws IllegalArgumentException because an account record without an ID cannot be reconstructed. This indicates corrupt or hand-edited persistence data.","triggerScenarios":"Calling Account.readAccountID(JsonObject) with a storage object missing the account ID property, e.g. deserializing accounts.json entries written by an older version or edited by hand.","commonSituations":"Manually editing or migrating accounts.json; upgrading HMCL across versions where the storage schema changed; truncated/corrupt storage files.","solutions":["Ensure the stored JsonObject contains the account ID property before parsing","Re-create the account (re-login) if its stored data is corrupt or incomplete","When migrating storage formats, copy/transform the ID field into the expected property"],"exampleFix":"// before\nAccountID id = Account.readAccountID(storage); // storage lacks id\n// after\nif (storage.has(Account.PROPERTY_ACCOUNT_ID)) {\n    AccountID id = Account.readAccountID(storage);\n}","handlingStrategy":"try-catch","validationCode":"if (storage == null || !storage.has(Account.PROPERTY_ACCOUNT_ID)) {\n    throw new IllegalArgumentException(\"Account storage lacks id; re-login required\");\n}","typeGuard":"boolean hasId = storage != null && storage.has(Account.PROPERTY_ACCOUNT_ID);\nAccountID id = hasId ? Account.readAccountID(storage) : null;","tryCatchPattern":"try {\n    AccountID id = Account.readAccountID(storage);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Corrupt account entry, skipping/re-login: {}\", e.getMessage());\n}","preventionTips":["Never hand-edit accounts.json","Validate storage schema after migrations","Re-login accounts whose stored fields are missing"],"tags":["minecraft","accounts","persistence","json","validation"],"backgroundTag":"missing-required-argument","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"}