paascloud/paascloud-master · error · ValidateCodeException
验证码处理器不存在
Error message
验证码处理器不存在
What it means
ValidateCodeProcessorHolder.findValidateCodeProcessor looks up a validate-code processor bean by convention: <type in lowercase> + 'ValidateCodeProcessor' (e.g. 'smsValidateCodeProcessor', 'imageValidateCodeProcessor'). If no such bean is registered in the holder's map, a ValidateCodeException '验证码处理器xxx不存在' is thrown.
Solutions
- Verify a @Component processor for that type exists and implements ValidateCodeProcessor
- Ensure the processor's package is covered by @ComponentScan / spring.factories configuration
- Confirm the requested type in the URL matches the processor's ValidateCodeType (case-insensitive)
- Check the application includes paascloud-security-core and its processor auto-configuration
Example fix
// before GET /code/emial -> typo, no processor 'emialValidateCodeProcessor' // after GET /code/email -> matches EmailValidateCodeProcessor bean
Defensive patterns
Strategy: validation
Validate before calling
String expected = type.toLowerCase() + "ValidateCodeProcessor"; boolean exists = applicationContext.containsBean(expected);
Try / catch
try { processorHolder.findValidateCodeProcessor(type); } catch (ValidateCodeException e) { return ResponseEntity.badRequest().body("不支持的验证码类型: " + type); } Prevention
- Keep processor bean names aligned with the naming convention
- Component-scan the package holding all processors
- Test each /code/{type} endpoint at startup
When it happens
Trigger: POSTing to a validate-code endpoint with a URL/type whose processor was never registered — e.g. /code/xxx where no XxxValidateCodeProcessor bean exists, or a misspelled type in the request path.
Common situations: Custom validate-code type added without providing a corresponding processor bean; spring bean scanning excluded the processor's package; typo in the controller's @PathVariable; module providing the processor not on classpath.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/109df4672a755bda.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-common/paascloud-security-core/src/main/java/com/paascloud/security/core/validate/code/ValidateCodeProcessorHolder.java:61
*
* @return validate code processor
*/
ValidateCodeProcessor findValidateCodeProcessor(ValidateCodeType type) {
return findValidateCodeProcessor(type.toString().toLowerCase());
}
/**
* Find validate code processor validate code processor.
*
* @param type the type
*
* @return validate code processor
*/
ValidateCodeProcessor findValidateCodeProcessor(String type) {
String name = type.toLowerCase() + ValidateCodeProcessor.class.getSimpleName();
ValidateCodeProcessor processor = validateCodeProcessors.get(name);
if (processor == null) {
throw new ValidateCodeException("验证码处理器" + name + "不存在");
}
return processor;
}
}
View on GitHub (pinned to 781281a950)