{"record":{"id":"1170c0acb6b33c3c","repo":"asLody/VirtualApp","slug":"authtokentype-is-null","errorCode":null,"errorMessage":"authTokenType is null","messagePattern":"authTokenType is null","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"VirtualApp/lib/src/main/java/com/lody/virtual/server/accounts/VAccountManagerService.java","lineNumber":347,"sourceCode":"                saveAllAccounts();\n                synchronized (authTokenRecords) {\n                    Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator();\n                    while (iterator.hasNext()) {\n                        AuthTokenRecord record = iterator.next();\n                        if (record.userId == userId && record.account.equals(account)) {\n                            iterator.remove();\n                        }\n                    }\n                }\n                sendAccountsChangedBroadcast(userId);\n            }\n        }\n    }\n\n    @Override\n    public void setAuthToken(int userId, Account account, String authTokenType, String authToken) {\n        if (account == null) throw new IllegalArgumentException(\"account is null\");\n        if (authTokenType == null) throw new IllegalArgumentException(\"authTokenType is null\");\n        synchronized (accountsByUserId) {\n            VAccount vAccount = getAccount(userId, account);\n            if (vAccount != null) {\n                // FIXME: cancelNotification\n                vAccount.authTokens.put(authTokenType, authToken);\n                this.saveAllAccounts();\n            }\n        }\n    }\n\n\n    @Override\n    public void setUserData(int userId, Account account, String key, String value) {\n        if (key == null) throw new IllegalArgumentException(\"key is null\");\n        if (account == null) throw new IllegalArgumentException(\"account is null\");\n        VAccount vAccount = getAccount(userId, account);\n        if (vAccount != null) {\n            synchronized (accountsByUserId) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/asLody/VirtualApp/blob/666fefcb5d3f39cc944001c3457c38ffd6544c87/VirtualApp/lib/src/main/java/com/lody/virtual/server/accounts/VAccountManagerService.java#L329-L365","documentation":"setAuthToken(userId, account, authTokenType, authToken) throws IllegalArgumentException('authTokenType is null') after the account null-check. The authTokenType is the map key under which the token is stored on the VAccount; a null key would make token lookup and Map operations unreliable, so the service rejects it.","triggerScenarios":"Calling setAuthToken with a null authTokenType — e.g. the token type comes from a Bundle extra that was never set (AccountManager.KEY_AUTHENTICATOR_TYPES or a custom constant missing), or a constant defined as null.","commonSituations":"Custom authenticator code where the token-type string constant was renamed or its config value lost; reading the type from an intent extra that is absent; typos making the variable unassigned.","solutions":["Pass a non-empty authTokenType string constant (e.g. 'com.example.token')","Validate the value read from Bundle/intent extras before calling setAuthToken","Define token types as compile-time constants rather than runtime-computed strings"],"exampleFix":"// before\nmanager.setAuthToken(userId, account, extras.getString(\"token_type\"), token);\n// after\nString tokenType = extras.getString(\"token_type\");\nif (account != null && tokenType != null) {\n    manager.setAuthToken(userId, account, tokenType, token);\n}","handlingStrategy":"validation","validationCode":"if (authTokenType == null || authTokenType.isEmpty()) { throw new IllegalStateException(\"authTokenType must be a non-empty constant\"); }","typeGuard":"boolean isValidTokenType(String t) { return t != null && !t.trim().isEmpty(); }","tryCatchPattern":null,"preventionTips":["Define token types as final String constants, never read from optional extras without defaults","Use extras.getString(KEY, DEFAULT) when reading token types from Bundles","Review renames of token-type constants for missed call sites"],"tags":["android","accounts","auth-token","null-argument"],"backgroundTag":"null-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"}