paascloud/paascloud-master · error · BusinessException
UAC10011039
UAC10011039
Error message
UAC10011039
What it means
RequestUtil.getLoginUser throws ErrorCodeEnum.UAC10011039 when no LoginAuthDto is present in the ThreadLocal under TOKEN_AUTH_DTO. Like BaseController.getLoginAuthDto, it signals that the current thread has no authenticated user — the request was unauthenticated or the auth layer never populated the ThreadLocal.
Solutions
- Ensure a valid Authorization token is present so the auth filter populates ThreadLocalMap before this call.
- For async work, capture LoginAuthDto in the request thread and pass it explicitly (or use a context-propagating decorator).
- Check interceptor path patterns so this endpoint is actually covered by authentication.
Example fix
// before (in @Async method) LoginAuthDto user = RequestUtil.getLoginUser(); // after LoginAuthDto user = RequestUtil.getLoginUser(); // capture in caller asyncService.doWork(user); // pass explicitly
Defensive patterns
Strategy: validation
Validate before calling
Object ctx = ThreadLocalMap.get(GlobalConstant.Sys.TOKEN_AUTH_DTO);
if (!(ctx instanceof LoginAuthDto)) {
throw new AuthenticationException("no login user bound to current thread");
} Try / catch
try {
LoginAuthDto user = RequestUtil.getLoginUser();
} catch (BusinessException e) {
return ResponseEntity.status(401).build();
} Prevention
- Capture LoginAuthDto in the request thread before dispatching async work.
- Use a TaskDecorator to propagate request context to worker threads.
- Confirm endpoints relying on getLoginUser are covered by the auth interceptor.
When it happens
Trigger: Calling RequestUtil.getLoginUser() from code executing without a populated ThreadLocalMap entry: no token, invalid/expired token, or calls from async threads (where ThreadLocal does not propagate).
Common situations: Internal service calls bypassing the gateway, @Async or thread-pool tasks losing the request context, expired JWTs, or endpoints excluded from the auth interceptor by mistake.
Related errors
- UAC10011041
- UAC10011040
- Failed to decode basic authentication token
- Invalid basic authentication token
- Authentication method not supported:
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/2c29e5e150496fda.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-common/paascloud-common-core/src/main/java/com/paascloud/core/utils/RequestUtil.java:112
}
// 对于通过多个代理的情况, 第一个IP为客户端真实IP,多个IP按照','分割 //"***.***.***.***".length() = 15
if (ipAddress != null && ipAddress.length() > GlobalConstant.MAX_IP_LENGTH) {
if (ipAddress.indexOf(GlobalConstant.Symbol.COMMA) > 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf(GlobalConstant.Symbol.COMMA));
}
}
return ipAddress;
}
/**
* Gets login user.
*
* @return the login user
*/
public static LoginAuthDto getLoginUser() {
LoginAuthDto loginAuthDto = (LoginAuthDto) ThreadLocalMap.get(GlobalConstant.Sys.TOKEN_AUTH_DTO);
if (PublicUtil.isEmpty(loginAuthDto)) {
throw new BusinessException(ErrorCodeEnum.UAC10011039);
}
return loginAuthDto;
}
/**
* Gets auth header.
*
* @param request the request
*
* @return the auth header
*/
public static String getAuthHeader(HttpServletRequest request) {
String authHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
if (org.apache.commons.lang.StringUtils.isEmpty(authHeader)) {
throw new BusinessException(ErrorCodeEnum.UAC10011040);
}View on GitHub (pinned to 781281a950)