{"record":{"id":"66299c9c5f3f1bea","repo":"paascloud/paascloud-master","slug":"error-66299c","errorCode":null,"errorMessage":"验证码的值不能为空","messagePattern":"验证码的值不能为空","errorType":"validation","errorClass":"ValidateCodeException","httpStatus":400,"severity":"error","filePath":"paascloud-common/paascloud-security-core/src/main/java/com/paascloud/security/core/validate/code/impl/AbstractValidateCodeProcessor.java","lineNumber":141,"sourceCode":"\t *\n\t * @param request the request\n\t */\n\t@SuppressWarnings(\"unchecked\")\n\t@Override\n\tpublic void check(ServletWebRequest request) {\n\t\tValidateCodeType codeType = getValidateCodeType();\n\n\t\tC codeInSession = (C) validateCodeRepository.get(request, codeType);\n\n\t\tString codeInRequest;\n\t\ttry {\n\t\t\tcodeInRequest = ServletRequestUtils.getStringParameter(request.getRequest(), codeType.getParamNameOnValidate());\n\t\t} catch (ServletRequestBindingException e) {\n\t\t\tthrow new ValidateCodeException(\"获取验证码的值失败\");\n\t\t}\n\n\t\tif (StringUtils.isBlank(codeInRequest)) {\n\t\t\tthrow new ValidateCodeException(codeType + \"验证码的值不能为空\");\n\t\t}\n\n\t\tif (codeInSession == null || codeInSession.isExpired()) {\n\t\t\tvalidateCodeRepository.remove(request, codeType);\n\t\t\tthrow new ValidateCodeException(codeType + \"验证码已过期\");\n\t\t}\n\n\t\tif (!StringUtils.equals(codeInSession.getCode(), codeInRequest)) {\n\t\t\tthrow new ValidateCodeException(codeType + \"验证码不匹配\");\n\t\t}\n\t}\n}\n","sourceCodeStart":123,"sourceCodeEnd":154,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-common/paascloud-security-core/src/main/java/com/paascloud/security/core/validate/code/impl/AbstractValidateCodeProcessor.java#L123-L154","documentation":"Fires in AbstractValidateCodeProcessor.check when the captcha parameter sent in the HTTP request (read via codeType.getParamNameOnValidate()) is blank. This is a validation guard ensuring the user actually submitted a code before it is compared against the code stored in the ValidateCodeRepository; the session code is never consulted. Client-side fix: submit the parameter matching the code type's paramNameOnValidate.","triggerScenarios":"Client submits the validate-code request with the parameter present but empty string (e.g. smsCode=).","commonSituations":"User clicked submit without entering the code; frontend sends empty field instead of omitting it; mobile app sending placeholder empty values.","solutions":["Client-side validate that the code input is non-empty before submitting","Show the user a prompt asking to enter the code","Server-side, catch ValidateCodeException and return a friendly 'code required' message"],"exampleFix":"// before\nif (!smsCode) { submit(); }\n// after\nif (!smsCode || !smsCode.trim()) { alert('请输入验证码'); return; }","handlingStrategy":"validation","validationCode":"if (code == null || code.trim().isEmpty()) { alert('请输入验证码'); return false; }","typeGuard":"function hasCode(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { processor.validate(request); } catch (ValidateCodeException e) { bindingResult.rejectValue(\"smsCode\", \"blank\", e.getMessage()); }","preventionTips":["Client-side required-field validation on the code input","Disable submit until the field is filled","Show server messages inline next to the field"],"tags":["validation-code","empty-value","input-validation"],"backgroundTag":"empty-required-field","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}