{"record":{"id":"f4d63127ebe1b51e","repo":"justauth/JustAuth","slug":"object-getstring-message","errorCode":null,"errorMessage":"object.getString(\"message\")","messagePattern":"object\\.getString\\(\"message\"\\)","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java","lineNumber":100,"sourceCode":"        String requestId = this.getRequestId();\n\n        Map<String, Object> paramsMap = new HashMap<>();\n        paramsMap.put(\"nop\", \"1.0.0\");\n        paramsMap.put(\"id\", requestId);\n        paramsMap.put(\"action\", action);\n        paramsMap.put(\"token\", authToken.getAccessToken());\n        paramsMap.put(\"metas\", metasHashMap);\n        paramsMap.put(\"params\", parameters);\n        paramsMap.put(\"signature\", signature);\n\n        HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_JSON, requestId, false);\n        String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), JSONObject.toJSONString(paramsMap), httpHeader).getBody();\n\n        JSONObject object = JSONObject.parseObject(response);\n\n        // 校验请求\n        if (object.containsKey(\"name\")) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n        if (object.containsKey(\"error\") && null != object.get(\"error\")) {\n            throw new AuthException(object.getJSONObject(\"error\").getString(\"message\"));\n        }\n\n        JSONObject result = object.getJSONObject(\"result\");\n\n        return AuthUser.builder()\n            .rawUserInfo(result)\n            .uuid(result.getString(\"userId\"))\n            .username(result.getString(\"userName\"))\n            .nickname(result.getString(\"userName\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java#L82-L118","documentation":"In AuthElemeRequest.getUserInfo(), if the response JSON contains a top-level 'name' key (Eleme's error envelope includes name+message), JustAuth throws AuthException with the 'message' field. Caveat: the guard checks 'name' but reads 'message', so if the payload has name without message the thrown text is null - capture the raw response in that case.","triggerScenarios":"Calling getUserInfo() on AuthElemeRequest when the Eleme open-platform returns an error object: invalid/expired token, missing API permission for the user scope, or a signature/params mismatch in the RPC wrapper.","commonSituations":"Eleme app not yet granted the '获取用户信息' API permission, token expired between login and the userinfo call, or system clock skew breaking the signature (which Eleme reports as a named error object).","solutions":["Check the Eleme open platform console that your app has the user-info API permission approved.","If the thrown message is null, log the HTTP response body directly to see the full error envelope (it contains name + message).","Verify server clock sync (NTP) - Eleme signatures include a timestamp and reject drift.","Call refresh() if the access token is older than its 30-day validity before requesting user info."],"exampleFix":"// before - message can be null when only 'name' is present\nif (object.containsKey(\"name\")) {\n    throw new AuthException(object.getString(\"message\"));\n}\n\n// after - always give the caller the actual payload\nif (object.containsKey(\"name\")) {\n    String msg = object.getString(\"message\");\n    throw new AuthException(msg != null ? msg : object.toJSONString());\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return elemeRequest.getUserInfo(token);\n} catch (AuthException e) {\n    // msg can be null when Eleme returns name without message\n    String safe = e.getErrorMsg() != null ? e.getErrorMsg() : \"Eleme user info failed\";\n    log.warn(\"Eleme error: {}\", safe);\n    return AuthResponse.builder().code(500).msg(safe).build();\n}","preventionTips":["Approve the user-info API permission for the Eleme app before shipping.","Run NTP on servers - Eleme signatures include timestamps and fail on drift.","Null-check AuthException.getErrorMsg() whenever you build user-facing error messages."],"tags":["oauth","eleme","justauth","api-error","null-message"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}