-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
Description
The org.springframework.web.bind.MissingPathVariableException is intended to return a 400 status code in case the value is missing after conversion. This is indicated by the getStatusCode() method:
@Override
public HttpStatusCode getStatusCode() {
return (isMissingAfterConversion() ? HttpStatus.BAD_REQUEST : HttpStatus.INTERNAL_SERVER_ERROR);
}However, when used in combination with a ProblemDetail, the status code set in the problem detail will always be 500. This is caused by the fact that the ProblemDetail instance is initialized during construction of ServletRequestBindingException before the missingAfterConversion field is initialized in MissingRequestValueException, resulting in the invocation of getStatusCode() (in ServletRequestBindingException) to always return HttpStatus.INTERNAL_SERVER_ERROR.
The http response code will be 400 as expected.
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug