Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorController should produce problem details if spring.mvc.problemdetails.enabled=true #34871

Closed
quaff opened this issue Apr 6, 2023 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@quaff
Copy link
Contributor

quaff commented Apr 6, 2023

Currently ErrorController will produce traditional error response even if problem details is enabled, nobody want to mix two different style of error handling.

    @RequestMapping("/")
    void home(HttpServletResponse response) throws IOException {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "bad.request");
    }
	@Test
	void sendErrorShouldProduceProblemDetails() {
		ResponseEntity<Map<String, Object>> resp = testRestTemplate.exchange(RequestEntity.method(GET, "/").build(),
				new ParameterizedTypeReference<Map<String, Object>>() {
				});
		assertThat(resp.getBody()).containsKey("detail");
	}
Expecting actual:
  {"error"="Bad Request", "message"="bad.request", "path"="/", "status"=400, "timestamp"="2023-04-06T02:01:46.401+00:00"}
to contain key:
  "detail"

Here is minimal project problemdetails.zip

@snicoll
Copy link
Member

snicoll commented Apr 7, 2023

Thanks for the report, this is a duplicate of #33885

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2023
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants