paascloud/paascloud-master · error · AppSecretException
设备id参数不能为空
Error message
设备id参数不能为空
What it means
AppSingUpUtils.getKey throws AppSecretException('设备id参数不能为空') when the request has no 'deviceId' header. The deviceId is required to build the Redis key ('pc:security:social.connect.' + deviceId) under which social connection data is cached. It is called by saveConnectionData and by getKey-based lookups in doPostSignUp.
Solutions
- Set a unique, stable 'deviceId' header on every social-login and signup request.
- If a gateway strips custom headers, whitelist/forward the deviceId header in your proxy configuration.
- Generate and persist a deviceId on the client (e.g. UUID in local storage) on first launch.
- For tests, include -H 'deviceId: <value>' in curl/Postman calls.
- Consider falling back to session id or another stable identifier for web clients.
Example fix
// before
webClient.post().uri("/social/signUp").bodyValue(form); // no header
// after
webClient.post().uri("/social/signUp")
.header("deviceId", deviceId)
.bodyValue(form); Defensive patterns
Strategy: validation
Validate before calling
String deviceId = request.getHeader("deviceId");
if (deviceId == null || deviceId.trim().isEmpty()) {
throw new IllegalArgumentException("deviceId header is required for social signup");
} Try / catch
try {
appSingUpUtils.doPostSignUp(request, userId);
} catch (AppSecretException e) {
if (e.getMessage().contains("设备id")) {
response.sendError(400, "deviceId header required");
}
} Prevention
- Generate and persist a deviceId on the client at first launch.
- Attach deviceId to every social-login/signup request.
- Ensure proxies/gateways forward the deviceId header.
- Add an API-contract test asserting the header is present.
When it happens
Trigger: Any call to saveConnectionData(request, connection) or doPostSignUp(request, userId) with a WebRequest lacking a non-blank 'deviceId' header — e.g. request from a browser/desktop client that never sets deviceId, or header stripped by a proxy/gateway.
Common situations: Mobile app updated without sending the new required deviceId header; nginx or API gateway not forwarding custom headers; developer testing signup endpoints with curl/Postman and forgetting the header; web client performing social signup where deviceId was never generated.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/9de2e3afd0b228cc.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-common/paascloud-security-app/src/main/java/com/paascloud/security/app/social/AppSingUpUtils.java:90
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)