paascloud/paascloud-master · warning · IllegalArgumentException

errorInfo

Error message

errorInfo

What it means

BindingResultAop.doAfter inspects controller method arguments for a Spring BindingResult after @Valid binding; if the binding result contains field errors, it throws IllegalArgumentException with the first field error's default message. This converts bean-validation failures (e.g. @NotBlank/@Size violations) into a plain runtime exception surfaced by the aspect.

Solutions

  1. Fix the client payload so it satisfies the validation annotations on the DTO.
  2. Read the message (first field error's defaultMessage) to identify which field violated which constraint.
  3. If the message is unhelpfully generic, replace the DTO's default constraint messages with explicit ones, or use @Validated with a global @ControllerAdvice exception handler.

Example fix

// before
public Result create(@RequestBody @Valid UserDto dto, BindingResult bindingResult) { ... }
// after — rely on the aspect, but give the constraint a clear message
@NotBlank(message = "userName must not be blank")
private String userName;
Defensive patterns

Strategy: try-catch

Validate before calling

// client side
if (!dto.userName || dto.userName.length > 20) {
    showFieldError("userName invalid");
    return;
}

Try / catch

try {
    ResponseEntity<Result> r = restTemplate.postForEntity(url, req, Result.class);
} catch (IllegalArgumentException e) {
    // message is the first field error's defaultMessage
    renderValidationError(e.getMessage());
}

Prevention

When it happens

Trigger: A request body or form parameter fails JSR-303 validation (e.g. @NotNull, @Length exceeded) on a controller method intercepted by this aspect, so bindingResult.hasErrors() is true.

Common situations: Clients POSTing missing required fields, fields over max length, malformed numbers/dates, or API version changes that relaxed/tightened validation annotations.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/0afe727ac6f2f0d0. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-common/paascloud-common-core/src/main/java/com/paascloud/core/aspect/BindingResultAop.java:74

	public void doAfter(final JoinPoint joinPoint) {
		String methodName = joinPoint.getSignature().getName();
		Object target = joinPoint.getTarget();
		//得到拦截的方法
		Method method = getMethodByClassAndName(target.getClass(), methodName);
		Object[] objects = joinPoint.getArgs();
		//方法的参数
		assert method != null;
		ValidateAnnotation annotation = (ValidateAnnotation) getAnnotationByMethod(method, ValidateAnnotation.class);
		if (annotation != null) {
			BindingResult bindingResult = null;
			for (Object arg : objects) {
				if (arg instanceof BindingResult) {
					bindingResult = (BindingResult) arg;
				}
			}
			if (bindingResult != null && bindingResult.hasErrors()) {
				String errorInfo = bindingResult.getFieldError().getDefaultMessage();
				throw new IllegalArgumentException(errorInfo);
			}
		}
	}

	/**
	 * 根据目标方法和注解类型  得到该目标方法的指定注解
	 */
	private Annotation getAnnotationByMethod(Method method, Class annoClass) {
		Annotation[] all = method.getAnnotations();
		for (Annotation annotation : all) {
			if (annotation.annotationType() == annoClass) {
				return annotation;
			}
		}
		return null;
	}

	/**

View on GitHub (pinned to 781281a950)