{"record":{"id":"53f68f216b5003f7","repo":"paascloud/paascloud-master","slug":"error-53f68f","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":146,"sourceCode":"\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":128,"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#L128-L154","documentation":"check compares the submitted code against the code stored in the ValidateCodeRepository. If no code exists in the repository or ValidateCode.isExpired() is true, the stored code is removed and '<TYPE>验证码已过期' is thrown.","triggerScenarios":"User waits past the code's expireSeconds TTL before submitting; no code was ever generated for this device/session; Redis restarted or the key was evicted (session/redis repository).","commonSituations":"Long delay between requesting and entering the SMS code; multiple devices sharing a deviceId overwriting each other's code; Redis maxmemory eviction; user requesting a new code then submitting the old one.","solutions":["Re-request a new validate code and submit it promptly","Increase expireSeconds in ValidateCodeProperties if the TTL is too short","Ensure deviceId header is stable per device so codes aren't overwritten","Check Redis persistence/eviction settings if codes vanish early"],"exampleFix":"// before\nsecurity.code.sms.expireSeconds=30\n// after\nsecurity.code.sms.expireSeconds=300","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { processor.validate(request); } catch (ValidateCodeException e) { if (e.getMessage().contains(\"已过期\")) { promptUserToResendCode(); } }","preventionTips":["Set generous but sane expireSeconds values","Prompt users to request a new code on expiry","Keep deviceId stable so keys aren't lost","Monitor Redis eviction policies"],"tags":["validation-code","expired","redis"],"backgroundTag":"verification-code-expired","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"}