qiurunze123/miaosha · error · GlobleException
10001
10001
Error message
系统错误
What it means
Thrown by MiaoShaUserService.login() (miaosha-v2) when the LoginVo argument is null. Maps to ResultStatus.SYSTEM_ERROR (code 10001, '系统错误'). This is a top-of-method null guard identical in purpose to v1's error 2. In v2, the LoginVo field is accessed via getNickname() instead of getMobile(), but the null check fires before any field access.
Source
Thrown at miaosha-v2/miaosha-service/src/main/java/com/geekq/miaosha/service/MiaoShaUserService.java:132
MiaoshaUser user = miaoShaUserMapper.getByNickname(miaoShaUser.getNickname());
if (user == null) {
return false;
}
//生成cookie 将session返回游览器 分布式session
String token = UUIDUtil.uuid();
addCookie(response, token, user);
} catch (Exception e) {
logger.error("注册失败", e);
return false;
}
return true;
}
public boolean login(HttpServletResponse response, LoginVo loginVo) {
if (loginVo == null) {
throw new GlobleException(SYSTEM_ERROR);
}
String mobile = loginVo.getNickname();
String password = loginVo.getPassword();
MiaoshaUser user = getByNickName(mobile);
if (user == null) {
throw new GlobleException(MOBILE_NOT_EXIST);
}
String dbPass = user.getPassword();
String saltDb = user.getSalt();
String calcPass = MD5Utils.formPassToDBPass(password, saltDb);
if (!calcPass.equals(dbPass)) {
throw new GlobleException(PASSWORD_ERROR);
}
//生成cookie 将session返回游览器 分布式session
String token = UUIDUtil.uuid();
addCookie(response, token, user);View on GitHub (pinned to e58017658e)
Solutions
- Add @Valid on the LoginVo controller parameter so Spring rejects null/malformed bodies at the web layer.
- Return a 400 from the controller when loginVo is null rather than invoking the service.
- Always construct LoginVo with setNickname() and setPassword() in tests.
Defensive patterns
Strategy: validation
Validate before calling
// Controller-layer guard (v2)
if (loginVo == null) {
return ResultGeekQ.error(ResultStatus.PARAM_ERROR);
}
return userService.login(response, loginVo); Type guard
// Ensure LoginVo is non-null with required fields (v2 uses getNickname)
if (loginVo == null || loginVo.getNickname() == null || loginVo.getPassword() == null) {
throw new IllegalArgumentException("LoginVo and its fields must not be null");
} Try / catch
try {
userService.login(response, loginVo);
} catch (GlobleException e) {
if (e.getStatus() == ResultStatus.SYSTEM_ERROR) {
return ResultGeekQ.error(ResultStatus.PARAM_ERROR);
}
throw e;
} Prevention
- Add @RequestBody @Valid on the LoginVo controller parameter.
- Populate both nickname and password fields in tests.
- Use @NotNull JSR-303 annotations on LoginVo fields.
When it happens
Trigger: Calling login(response, null) from a controller where the LoginVo failed to bind, or from test code that did not construct the object. The controller likely uses @RequestBody or @ModelAttribute without @Valid.
Common situations: Malformed JSON login body that Spring cannot deserialize into LoginVo; controller passes the raw null through; integration test omitting the LoginVo argument.
Related errors
AI-assisted analysis of qiurunze123/miaosha@e58017658e (2026-08-14).
Data as JSON: /api/errors/427615e9114f6383.
Report an issue: GitHub.