{"record":{"id":"e4ef4be1193ce044","repo":"qiurunze123/miaosha","slug":"30009","errorCode":"30009","errorMessage":"手机号不存在!","messagePattern":"手机号不存在!","errorType":"exception","errorClass":"GlobleException","httpStatus":null,"severity":"warning","filePath":"miaosha-v1/src/main/java/com/geekq/miaosha/service/MiaoShaUserService.java","lineNumber":73,"sourceCode":"        MiaoshaUser user = redisService.get(MiaoShaUserKey.getByNickName, \"\" + nickName, MiaoshaUser.class);\n        if (user != null) {\n            return user;\n        }\n        //取数据库\n        user = miaoShaUserDao.getByNickname(nickName);\n        if (user != null) {\n            redisService.set(MiaoShaUserKey.getByNickName, \"\" + nickName, user);\n        }\n        return user;\n    }\n\n\n    // http://blog.csdn.net/tTU1EvLDeLFq5btqiK/article/details/78693323\n    public boolean updatePassword(String token, String nickName, String formPass) {\n        //取user\n        MiaoshaUser user = getByNickName(nickName);\n        if (user == null) {\n            throw new GlobleException(MOBILE_NOT_EXIST);\n        }\n        //更新数据库\n        MiaoshaUser toBeUpdate = new MiaoshaUser();\n        toBeUpdate.setNickname(nickName);\n        toBeUpdate.setPassword(MD5Utils.formPassToDBPass(formPass, user.getSalt()));\n        miaoShaUserDao.update(toBeUpdate);\n        //处理缓存\n        redisService.delete(MiaoShaUserKey.getByNickName, \"\" + nickName);\n        user.setPassword(toBeUpdate.getPassword());\n        redisService.set(MiaoShaUserKey.token, token, user);\n        return true;\n    }\n\n\n    public boolean register(HttpServletResponse response, String userName, String passWord, String salt) {\n        MiaoshaUser miaoShaUser = new MiaoshaUser();\n        miaoShaUser.setNickname(userName);\n        String DBPassWord = MD5Utils.formPassToDBPass(passWord, salt);","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/qiurunze123/miaosha/blob/e58017658e549b63fc4db2160d2325ccd7f8435b/miaosha-v1/src/main/java/com/geekq/miaosha/service/MiaoShaUserService.java#L55-L91","documentation":"Thrown by MiaoShaUserService.updatePassword() (miaosha-v1) when getByNickName(nickName) returns null. Maps to ResultStatus.MOBILE_NOT_EXIST (code 30009, message '手机号不存在!' — 'Phone number does not exist'). The lookup goes through a Redis cache (MiaoShaUserKey.getByNickName) then falls back to miaoShaUserDao.getByNickname(). If both miss, the user does not exist in the system. The message is misleading because the lookup key is a nickname, not a phone number — this is a known v1 wording issue corrected to '账号不存在!' in v2.","triggerScenarios":"Calling updatePassword(token, nickName, formPass) where nickName has no matching row in the miaosha_user table and is not cached in Redis. This occurs when a user tries to change a password for an account that was never registered, was deleted, or when the nickname is mistyped.","commonSituations":"Stale client holding a token for a deleted account; typo in the nickname field; test environment with an empty user table; Redis was flushed so the cache miss exposes a missing DB row; user was registered in a different data center / shard.","solutions":["Verify the user exists via getByNickName(nickName) before presenting the password-change form to the user.","Ensure the nickname passed to updatePassword() matches the one used at registration time (case-sensitive).","If the account was deleted, re-register it before attempting a password change.","Check that the miaosha_user table is populated and the DAO query getByNickname maps the correct column."],"exampleFix":"// before\nMiaoshaUser user = getByNickName(nickName);\nif (user == null) {\n    throw new GlobleException(MOBILE_NOT_EXIST);\n}\n\n// after — caller validates first\nMiaoshaUser existing = miaoShaUserService.getByNickName(nickName);\nif (existing == null) {\n    return ResultGeekQ.error(MOBILE_NOT_EXIST);\n}\nmiaoShaUserService.updatePassword(token, nickName, formPass);","handlingStrategy":"validation","validationCode":"// Verify user exists before password update\nMiaoshaUser user = miaoShaUserService.getByNickName(nickName);\nif (user == null) {\n    return ResultGeekQ.error(ResultStatus.MOBILE_NOT_EXIST);\n}\nmiaoShaUserService.updatePassword(token, nickName, formPass);","typeGuard":null,"tryCatchPattern":"try {\n    miaoShaUserService.updatePassword(token, nickName, formPass);\n} catch (GlobleException e) {\n    if (e.getStatus() == ResultStatus.MOBILE_NOT_EXIST) {\n        return ResultGeekQ.error(MOBILE_NOT_EXIST);\n    }\n    throw e;\n}","preventionTips":["Pre-validate user existence via getByNickName() before showing the password-reset form.","Ensure the nickname field is trimmed and case-normalized before lookup.","Log which nickname failed to help diagnose stale-account issues."],"tags":["authentication","password-reset","user-not-found","miaosha-v1"],"backgroundTag":null,"analyzedSha":"e58017658e549b63fc4db2160d2325ccd7f8435b","analyzedAt":"2026-08-14T05:22:03.691Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}