{"record":{"id":"e0afce2abbfd2d09","repo":"asLody/VirtualApp","slug":"accounttype-is-null","errorCode":null,"errorMessage":"accountType is null","messagePattern":"accountType is null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"VirtualApp/lib/src/main/java/com/lody/virtual/client/ipc/VAccountManager.java","lineNumber":261,"sourceCode":"            return VirtualRuntime.crash(e);\n        }\n    }\n\n    /**\n     * Asks the user to add an account of a specified type.  The authenticator\n     * for this account type processes this request with the appropriate user\n     * interface.  If the user does elect to create a new account, the account\n     * name is returned.\n     * <p>\n     * <p>This method may be called from any thread, but the returned\n     * {@link AccountManagerFuture} must not be used on the main thread.\n     * <p>\n     */\n    public AccountManagerFuture<Bundle> addAccount(final int userId, final String accountType,\n                                                   final String authTokenType, final String[] requiredFeatures,\n                                                   final Bundle addAccountOptions,\n                                                   final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {\n        if (accountType == null) throw new IllegalArgumentException(\"accountType is null\");\n        final Bundle optionsIn = new Bundle();\n        if (addAccountOptions != null) {\n            optionsIn.putAll(addAccountOptions);\n        }\n        optionsIn.putString(KEY_ANDROID_PACKAGE_NAME, \"android\");\n\n        return new AmsTask(activity, handler, callback) {\n            @Override\n            public void doWork() throws RemoteException {\n                addAccount(userId, mResponse, accountType, authTokenType,\n                        requiredFeatures, activity != null, optionsIn);\n            }\n        }.start();\n    }\n}\n","sourceCodeStart":243,"sourceCodeEnd":277,"githubUrl":"https://github.com/asLody/VirtualApp/blob/666fefcb5d3f39cc944001c3457c38ffd6544c87/VirtualApp/lib/src/main/java/com/lody/virtual/client/ipc/VAccountManager.java#L243-L277","documentation":"VAccountManager.addAccount mirrors Android's AccountManager and requires a non-null accountType to identify the account authenticator. Passing null accountType throws IllegalArgumentException immediately before building the request Bundle.","triggerScenarios":"Calling vAccountManager.addAccount(userId, null, ...) with a null accountType — e.g., the type string comes from a missing config, an Account whose type is null, or a refactor dropping the constant.","commonSituations":"Plugin authenticator metadata not parsed so type is null; hard-coded account type typo replaced by null default; upstream Account.getType() returning null for malformed accounts.","solutions":["Pass a non-empty account type string matching your Authenticator's accountType attribute","Validate the type argument before calling addAccount","If the type comes from an Account object, ensure the account was created with a valid type"],"exampleFix":"// before\nam.addAccount(userId, null, null, null, options, activity, callback, handler);\n// after\nam.addAccount(userId, \"com.example.myaccount\", null, null, options, activity, callback, handler);","handlingStrategy":"validation","validationCode":"if (accountType == null || accountType.isEmpty()) throw new IllegalArgumentException(\"accountType required before addAccount\");","typeGuard":"String safeType(String t) { return (t == null || t.isEmpty()) ? DEFAULT_ACCOUNT_TYPE : t; }","tryCatchPattern":"try { am.addAccount(userId, type, ...); } catch (IllegalArgumentException e) { Log.e(TAG, \"accountType missing\", e); }","preventionTips":["Define the account type as a constant shared with the authenticator","Never derive account type from nullable Account.getType() without fallback","Validate config-supplied account types at startup"],"tags":["android","account","null-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"666fefcb5d3f39cc944001c3457c38ffd6544c87","analyzedAt":"2026-09-09T11:09:01.694Z","contentChangedAt":"2026-09-09T11:09:01.694Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}