asLody/VirtualApp · error · java.lang.IllegalArgumentException

accountType is null

Error message

accountType is null

What it means

Thrown as an IllegalArgumentException at the top of getAccountsByFeatures when the caller passes a null account type. This is a generic boundary-validation guard: the service needs a concrete account type to resolve its registered authenticator via getAuthenticatorInfo and start a feature-matching session, so a null type makes the query meaningless. The input at fault is the 'type' parameter supplied by the IPC caller (e.g., AccountManager.getAccountsByTypeAndFeature invoked with a null type).

Solutions

  1. Pass a non-null account type string matching a registered authenticator
  2. Check the client bundle/extra (AccountManager.KEY_ACCOUNT_TYPE) is populated before the call
  3. Default the type from the authenticator metadata instead of an unset variable

Example fix

// before
String type = bundle.getString(AccountManager.KEY_ACCOUNT_TYPE); // null
mService.getAccountsByFeatures(userId, response, type, features);
// after
String type = bundle.getString(AccountManager.KEY_ACCOUNT_TYPE);
if (type == null) type = "com.example.account";
mService.getAccountsByFeatures(userId, response, type, features);
Defensive patterns

Strategy: validation

Validate before calling

if (type == null || type.isEmpty()) {
    throw new IllegalArgumentException("accountType must be non-empty");
}
mService.getAccountsByFeatures(userId, response, type, features);

Try / catch

try {
    mService.getAccountsByFeatures(userId, response, type, features);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().contains("accountType is null")) {
        // read type from authenticator config or defaults before retrying
    }
}

Prevention

When it happens

Trigger: Calling getAccountsByFeatures(userId, response, null, features) — typically from client code where the accountType was never set or was read from a null extra/bundle key.

Common situations: AccountManager request built without KEY_ACCOUNT_TYPE; missing intent extra; config parsing returned null for the authenticator type.

Related errors


AI-assisted analysis of asLody/VirtualApp@666fefcb5d (2026-09-09). Data as JSON: /api/errors/8824c76cdc4c3aae. Report an issue: GitHub.

Appendix: source

Thrown at VirtualApp/lib/src/main/java/com/lody/virtual/server/accounts/VAccountManagerService.java:126


    @Override
    public AuthenticatorDescription[] getAuthenticatorTypes(int userId) {
        synchronized (cache) {
            AuthenticatorDescription[] descArray = new AuthenticatorDescription[cache.authenticators.size()];
            int i = 0;
            for (AuthenticatorInfo info : cache.authenticators.values()) {
                descArray[i] = info.desc;
                i++;
            }
            return descArray;
        }
    }

    @Override
    public void getAccountsByFeatures(int userId, IAccountManagerResponse response, String type, String[] features) {
        if (response == null) throw new IllegalArgumentException("response is null");
        if (type == null) throw new IllegalArgumentException("accountType is null");
        AuthenticatorInfo info = getAuthenticatorInfo(type);
        if (info == null) {
            Bundle bundle = new Bundle();
            bundle.putParcelableArray(AccountManager.KEY_ACCOUNTS, new Account[0]);
            try {
                response.onResult(bundle);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            return;
        }

        if (features == null || features.length == 0) {
            Bundle bundle = new Bundle();
            bundle.putParcelableArray(AccountManager.KEY_ACCOUNTS, getAccounts(userId, type));
            try {
                response.onResult(bundle);
            } catch (RemoteException e) {

View on GitHub (pinned to 666fefcb5d)