paascloud/paascloud-master · error · AppSecretException

无法找到缓存的用户社交账号信息

Error message

无法找到缓存的用户社交账号信息

What it means

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.

Solutions

  1. Send the same deviceId header used during saveConnectionData with the signup request.
  2. Re-run the social authentication step to repopulate the cached ConnectionData, then immediately call doPostSignUp.
  3. Check Redis for the key 'pc:security:social.connect.<deviceId>' and review its TTL; increase TTL if the flow can be slow.
  4. Verify both requests go through the same Redis instance (same spring.redis config per environment).
  5. Persist the connection directly instead of relying on the cache for long-running signup flows.

Example fix

// before
// signup request without deviceId header
POST /user/register  {"username":"tom"}
// after
POST /user/register
Headers: deviceId: 8f3a-...
{"username":"tom"}
Defensive patterns

Strategy: validation

Validate before calling

String key = "pc:security:social.connect." + deviceId;
if (deviceId == null || deviceId.isBlank() || !Boolean.TRUE.equals(redisTemplate.hasKey(key))) {
    // re-run social auth to repopulate cache before signup
}

Try / catch

try {
    appSingUpUtils.doPostSignUp(request, userId);
} catch (AppSecretException e) {
    log.warn("social connection cache missing, restart social auth", e);
    return redirectToSocialAuth();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/29450b6fa65cee67. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-common/paascloud-security-app/src/main/java/com/paascloud/security/app/social/AppSingUpUtils.java:74

	 * 缓存社交网站用户信息到redis
	 *
	 * @param request        the request
	 * @param connectionData the connection data
	 */
	public void saveConnectionData(WebRequest request, ConnectionData connectionData) {
		redisTemplate.opsForValue().set(getKey(request), connectionData, 10, TimeUnit.MINUTES);
	}

	/**
	 * 将缓存的社交网站用户信息与系统注册用户信息绑定
	 *
	 * @param request the request
	 * @param userId  the user id
	 */
	public void doPostSignUp(WebRequest request, String userId) {
		String key = getKey(request);
		if (!redisTemplate.hasKey(key)) {
			throw new AppSecretException("无法找到缓存的用户社交账号信息");
		}
		ConnectionData connectionData = (ConnectionData) redisTemplate.opsForValue().get(key);
		Connection<?> connection = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId())
				.createConnection(connectionData);
		usersConnectionRepository.createConnectionRepository(userId).addConnection(connection);

		redisTemplate.delete(key);
	}

	/**
	 * 获取redis key
	 */
	private String getKey(WebRequest request) {
		String deviceId = request.getHeader("deviceId");
		if (StringUtils.isBlank(deviceId)) {
			throw new AppSecretException("设备id参数不能为空");
		}
		return "pc:security:social.connect." + deviceId;

View on GitHub (pinned to 781281a950)