{"record":{"id":"a0b01554bd06ac85","repo":"justauth/JustAuth","slug":"object-getstring-message-a0b015","errorCode":null,"errorMessage":"object.getString(\"message\")","messagePattern":"object\\.getString\\(\"message\"\\)","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"warning","filePath":"src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java","lineNumber":114,"sourceCode":"     * @param authToken token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"fields\", \"id,username,first_name,last_name,bio,image\")\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (!object.containsKey(\"status\") && FAILURE.equals(object.getString(\"status\"))) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n    }\n\n}\n","sourceCodeStart":96,"sourceCodeEnd":119,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java#L96-L119","documentation":"AuthPinterestRequest.checkResponse intends to throw AuthException with the 'message' field when status equals FAILURE, but the guard '!object.containsKey(\"status\") && FAILURE.equals(object.getString(\"status\"))' is logically dead: it requires the status key to be ABSENT while simultaneously equal to 'failure', which can never both hold. In practice this exception is never thrown, so Pinterest errors surface later as NPEs/parse failures instead.","triggerScenarios":"Any Pinterest API error response (failed token exchange, invalid token) — the intended trigger — but the broken condition means the throw is unreachable; the error leaks out downstream as missing-field NPEs (e.g. getString on a null node).","commonSituations":"Developers debug why Pinterest failures produce NullPointerException in getUserInfo rather than a clean AuthException; Pinterest API v5 also changed response shapes vs the v1 this code targeted.","solutions":["Upgrade JustAuth to a version where the condition is fixed to object.containsKey(\"status\") && \"failure\".equals(object.getString(\"status\")) or equivalent","If pinned to this version, wrap Pinterest calls in try-catch for both AuthException and NullPointerException and inspect the raw response","Verify Pinterest app credentials and scopes independently of this (non-firing) check","Migrate to Pinterest API v5 endpoints if you control the source config"],"exampleFix":"// before (dead condition — never throws)\nif (!object.containsKey(\"status\") && FAILURE.equals(object.getString(\"status\"))) {\n    throw new AuthException(object.getString(\"message\"));\n}\n\n// after (correct guard)\nif (FAILURE.equals(object.getString(\"status\"))) {\n    throw new AuthException(object.getString(\"message\"));\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    return pinterestRequest.getUserInfo(token);\n} catch (AuthException | NullPointerException e) {\n    // this JustAuth version's checkResponse is dead code; errors surface as NPEs\n    log.warn(\"Pinterest user info failed: {}\", e.getMessage(), e);\n    throw new AuthenticationServiceException(\"Pinterest login failed\", e);\n}","preventionTips":["Upgrade JustAuth to a release fixing the inverted containsKey condition","Wrap Pinterest calls for both AuthException and NPE while on affected versions","Verify Pinterest API v5 credentials/scopes separately since v1 endpoints are retired"],"tags":["oauth","pinterest","logic-bug","dead-code","auth-exception"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}