{"record":{"id":"20c5475749e459d2","repo":"paascloud/paascloud-master","slug":"error-20c547","errorCode":null,"errorMessage":"获取用户信息失败","messagePattern":"获取用户信息失败","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"paascloud-common/paascloud-security-core/src/main/java/com/paascloud/security/core/social/qq/api/QQImpl.java","lineNumber":78,"sourceCode":"\t * Gets user info.\n\t *\n\t * @return the user info\n\t */\n\t@Override\n\tpublic QQUserInfo getUserInfo() {\n\n\t\tString url = String.format(URL_GET_USERINFO, appId, openId);\n\t\tString result = getRestTemplate().getForObject(url, String.class);\n\n\t\tlog.info(\"result={}\", result);\n\n\t\tQQUserInfo userInfo;\n\t\ttry {\n\t\t\tuserInfo = objectMapper.readValue(result, QQUserInfo.class);\n\t\t\tuserInfo.setOpenId(openId);\n\t\t\treturn userInfo;\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"获取用户信息失败\", e);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":60,"sourceCodeEnd":83,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-common/paascloud-security-core/src/main/java/com/paascloud/security/core/social/qq/api/QQImpl.java#L60-L83","documentation":"QQImpl.getUserInfo parses the JSON returned by QQ's user-info endpoint into a QQUserInfo object using Jackson's ObjectMapper. If the response body is not valid QQUserInfo-shaped JSON (or openId cannot be attached), a RuntimeException with message '获取用户信息失败' is thrown, wrapping the original exception.","triggerScenarios":"QQ's graph API returned malformed, empty, or error JSON (e.g. invalid access_token, expired token) so objectMapper.readValue(result, QQUserInfo.class) throws; also any IO/network failure producing an unexpected string in `result`.","commonSituations":"Expired or revoked QQ access token; app id/secret mismatch so QQ returns an error payload instead of user info; network proxies returning HTML error pages; QQ API schema changes.","solutions":["Log/inspect the raw `result` string to see what QQ actually returned","Verify the access_token and openId are valid by calling QQ's token inspection endpoint","Check the QQ互联 app configuration (appId/appSecret, callback domain)","Decode the QQ error code (e.g. 100016 invalid token) and refresh/re-authenticate the user","Wrap with a domain-specific exception instead of raw RuntimeException for better upstream handling"],"exampleFix":"// before\nthrow new RuntimeException(\"获取用户信息失败\", e);\n// after\nlog.error(\"QQ getUserInfo failed, raw result: {}\", result, e);\nthrow new OAuth2Exception(\"获取用户信息失败: \" + result, e);","handlingStrategy":"try-catch","validationCode":"if (result == null || !result.trim().startsWith(\"{\")) { throw new IllegalArgumentException(\"QQ响应非JSON: \" + result); }","typeGuard":"function isQQUserInfo(o) { return o && typeof o === 'object' && 'openId' in o; }","tryCatchPattern":"try { QQUserInfo u = qqService.getUserInfo(openId); } catch (RuntimeException e) { log.error(\"QQ用户信息获取失败\", e); response.redirect(\"/social/qq/error\"); }","preventionTips":["Log the raw upstream response for diagnosis","Validate access_token before fetching user info","Monitor QQ error codes and refresh tokens proactively"],"tags":["oauth","qq","json","social-login"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}