{"record":{"id":"acd39adf2fcdf761","repo":"wuyouzhuguli/SpringAll","slug":"error-acd39a","errorCode":null,"errorMessage":"验证码不能为空！","messagePattern":"验证码不能为空！","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"64.Spring-Security-OAuth2-Customize/src/main/java/cc/mrbird/security/validate/smscode/SmsCodeFilter.java","lineNumber":49,"sourceCode":"                && StringUtils.equalsIgnoreCase(httpServletRequest.getMethod(), \"post\")) {\n            try {\n                validateCode(new ServletWebRequest(httpServletRequest));\n            } catch (Exception e) {\n                authenticationFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, new AuthenticationServiceException(e.getMessage()));\n                return;\n            }\n        }\n        filterChain.doFilter(httpServletRequest, httpServletResponse);\n    }\n\n    private void validateCode(ServletWebRequest servletWebRequest) throws Exception {\n        String smsCodeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), \"smsCode\");\n        String mobileInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), \"mobile\");\n\n        String codeInRedis = redisCodeService.get(servletWebRequest, mobileInRequest);\n\n        if (StringUtils.isBlank(smsCodeInRequest)) {\n            throw new Exception(\"验证码不能为空！\");\n        }\n        if (codeInRedis == null) {\n            throw new Exception(\"验证码已过期！\");\n        }\n        if (!StringUtils.equalsIgnoreCase(codeInRedis, smsCodeInRequest)) {\n            throw new Exception(\"验证码不正确！\");\n        }\n        redisCodeService.remove(servletWebRequest, mobileInRequest);\n\n    }\n}","sourceCodeStart":31,"sourceCodeEnd":60,"githubUrl":"https://github.com/wuyouzhuguli/SpringAll/blob/614d2578d9495acf53cc02f2dee9c6131cc5e51a/64.Spring-Security-OAuth2-Customize/src/main/java/cc/mrbird/security/validate/smscode/SmsCodeFilter.java#L31-L60","documentation":"Generic java.lang.Exception thrown by SmsCodeFilter.validateCode (project 64) when the 'smsCode' request parameter is blank, before the Redis lookup. Note this project throws plain Exception (caught by doFilterInternal and wrapped in AuthenticationServiceException), unlike project 61's ValidateCodeException.","triggerScenarios":"POST to /login/mobile where the 'smsCode' form/query parameter is missing or empty.","commonSituations":"Frontend omitted smsCode; field misnamed; SMS never received so left blank.","solutions":["Include a non-empty 'smsCode' parameter in the /login/mobile POST body.","Verify the frontend binds the SMS input to the key 'smsCode'.","Frontend should disable submit until the code field is filled."],"exampleFix":"// before\n// fetch('/login/mobile', { method:'POST', body:'mobile=13800000000' })\n\n// after\nfetch('/login/mobile', {\n  method:'POST',\n  headers:{ 'deviceId':id },\n  body:'mobile=13800000000&smsCode=123456'\n});","handlingStrategy":"validation","validationCode":"// Validate the SMS code field before submit.\nconst code = form.get('smsCode');\nif (!code || !code.trim()) { showFieldError('smsCode','请输入短信验证码'); return; }","typeGuard":null,"tryCatchPattern":"try { await smsLogin(); }\ncatch (e) {\n  if (/不能为空/.test(e.message)) showFieldError('smsCode','请输入短信验证码');\n  else handleError(e);\n}","preventionTips":["Bind the SMS input to name 'smsCode'.","Disable submit until the code is filled.","Send the deviceId header on the same request (required by RedisCodeService)."],"tags":["spring-security","sms","captcha","validation","oauth2"],"backgroundTag":null,"analyzedSha":"614d2578d9495acf53cc02f2dee9c6131cc5e51a","analyzedAt":"2026-08-14T04:40:03.488Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}