{"record":{"id":"29450b6fa65cee67","repo":"paascloud/paascloud-master","slug":"error-29450b","errorCode":null,"errorMessage":"无法找到缓存的用户社交账号信息","messagePattern":"无法找到缓存的用户社交账号信息","errorType":"exception","errorClass":"AppSecretException","httpStatus":null,"severity":"error","filePath":"paascloud-common/paascloud-security-app/src/main/java/com/paascloud/security/app/social/AppSingUpUtils.java","lineNumber":74,"sourceCode":"\t * 缓存社交网站用户信息到redis\n\t *\n\t * @param request        the request\n\t * @param connectionData the connection data\n\t */\n\tpublic void saveConnectionData(WebRequest request, ConnectionData connectionData) {\n\t\tredisTemplate.opsForValue().set(getKey(request), connectionData, 10, TimeUnit.MINUTES);\n\t}\n\n\t/**\n\t * 将缓存的社交网站用户信息与系统注册用户信息绑定\n\t *\n\t * @param request the request\n\t * @param userId  the user id\n\t */\n\tpublic void doPostSignUp(WebRequest request, String userId) {\n\t\tString key = getKey(request);\n\t\tif (!redisTemplate.hasKey(key)) {\n\t\t\tthrow new AppSecretException(\"无法找到缓存的用户社交账号信息\");\n\t\t}\n\t\tConnectionData connectionData = (ConnectionData) redisTemplate.opsForValue().get(key);\n\t\tConnection<?> connection = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId())\n\t\t\t\t.createConnection(connectionData);\n\t\tusersConnectionRepository.createConnectionRepository(userId).addConnection(connection);\n\n\t\tredisTemplate.delete(key);\n\t}\n\n\t/**\n\t * 获取redis key\n\t */\n\tprivate String getKey(WebRequest request) {\n\t\tString deviceId = request.getHeader(\"deviceId\");\n\t\tif (StringUtils.isBlank(deviceId)) {\n\t\t\tthrow new AppSecretException(\"设备id参数不能为空\");\n\t\t}\n\t\treturn \"pc:security:social.connect.\" + deviceId;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-common/paascloud-security-app/src/main/java/com/paascloud/security/app/social/AppSingUpUtils.java#L56-L92","documentation":"AppSingUpUtils.doPostSignUp throws AppSecretException('无法找到缓存的用户社交账号信息') when the redis key that should hold the cached ConnectionData for the social signup does not exist. During app social login the provider connection is cached in Redis (keyed by deviceId) and must be retrieved here to bind it to the new/registered user.","triggerScenarios":"Calling doPostSignUp(request, userId) when redisTemplate.hasKey(key) is false: the connection data was never saved via saveConnectionData, the Redis key expired (TTL), a different deviceId header was sent, or Redis was flushed/restarted between the social login and the signup call.","commonSituations":"Frontend drops the deviceId header between the login and signup requests; Redis eviction or restart clears the temporary connection; signup flow executed long after social auth so the TTL lapsed; multiple devices sharing sessions with mismatched deviceId values.","solutions":["Send the same deviceId header used during saveConnectionData with the signup request.","Re-run the social authentication step to repopulate the cached ConnectionData, then immediately call doPostSignUp.","Check Redis for the key 'pc:security:social.connect.<deviceId>' and review its TTL; increase TTL if the flow can be slow.","Verify both requests go through the same Redis instance (same spring.redis config per environment).","Persist the connection directly instead of relying on the cache for long-running signup flows."],"exampleFix":"// before\n// signup request without deviceId header\nPOST /user/register  {\"username\":\"tom\"}\n// after\nPOST /user/register\nHeaders: deviceId: 8f3a-...\n{\"username\":\"tom\"}","handlingStrategy":"validation","validationCode":"String key = \"pc:security:social.connect.\" + deviceId;\nif (deviceId == null || deviceId.isBlank() || !Boolean.TRUE.equals(redisTemplate.hasKey(key))) {\n    // re-run social auth to repopulate cache before signup\n}","typeGuard":null,"tryCatchPattern":"try {\n    appSingUpUtils.doPostSignUp(request, userId);\n} catch (AppSecretException e) {\n    log.warn(\"social connection cache missing, restart social auth\", e);\n    return redirectToSocialAuth();\n}","preventionTips":["Always send the same deviceId header through login and signup.","Give the Redis key a TTL long enough for slow signup flows.","Avoid restarting/flushing Redis mid-signup.","Persist connection to DB promptly after signup."],"tags":["java","spring-social","redis","cache-miss","signup"],"backgroundTag":"cache-miss","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"}