I checked the release notes and saw the change in depedencies, but there's no mention of changes in behauviour in validations.
We have a project in 2.2.10 that uses validations for input classes in RestController and error returns errors
and message
fields informed. However, after upgrade to 2.3.0, errors
is not returned and message
is always empty.
According to logs, the validation is applied and message processed but they are just not returned.
.log output
Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public usecase.service.UseCase usecase.http.UseCaseController.createUseCase(usecase.http.UseCaseInput): [Field error in object 'useCaseInput' on field 'code': rejected value [null]; codes [NotEmpty.useCaseInput.code,NotEmpty.code,NotEmpty.java.lang.String,NotEmpty]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [useCaseInput.code,code]; arguments []; default message [code]]; default message [Code is mandatory]] ]
2.2.x response is
{
"timestamp": "2020-10-06T11:28:13.214+0000",
"status": 400,
"error": "Bad Request",
"errors": [
{
"codes": [
"NotEmpty.useCaseInput.code",
"NotEmpty.code",
"NotEmpty.java.lang.String",
"NotEmpty"
],
"arguments": [
{
"codes": [
"useCaseInput.code",
"code"
],
"arguments": null,
"defaultMessage": "code",
"code": "code"
}
],
"defaultMessage": "Code is mandatory",
"objectName": "useCaseInput",
"field": "code",
"rejectedValue": null,
"bindingFailure": false,
"code": "NotEmpty"
}
],
"message": "Validation failed for object='useCaseInput'. Error count: 1",
"path": "/usecases"
}
2.3.x response is
{
"timestamp": "2020-10-06T11:30:01.640+00:00",
"status": 400,
"error": "Bad Request",
"message": "",
"path": "/usecases"
}
Comment From: wilkinsona
This is due to a change in the error page's defaults. Please see this section in the release notes for details.
Comment From: abelsromero
Thanks a lot for the quick response.