quarkusio/quarkus · error · HandledResponseEntityException
bad state
Error message
bad state
What it means
responseEntityWithResponseEntityException throws HandledResponseEntityException('bad state') from an endpoint whose return type is ResponseEntity<Greeting>. 'Handled' means a mapper exists that converts it into an error ResponseEntity — typically HTTP 409/500 carrying the message — and this endpoint tests that mapping for the ResponseEntity return type.
Source
Thrown at integration-tests/spring-web/src/main/java/io/quarkus/it/spring/web/ExceptionThrowingController.java:38
@GetMapping(path = "/unhandled/runtime")
public String stringWithUnhandledAnnotatedRuntimeException() {
throw new UnhandledAnnotatedRuntimeException();
}
@GetMapping("/runtime")
public void voidWithRuntimeException() {
throw new RuntimeException();
}
@GetMapping("/unannotated")
public void voidWithUnannotatedException() {
throw new HandledUnannotatedException();
}
@GetMapping("/re/re")
public ResponseEntity<Greeting> responseEntityWithResponseEntityException() {
throw new HandledResponseEntityException("bad state");
}
@GetMapping("/re/pojo")
public Greeting pojoWithResponseEntityException() {
throw new HandledResponseEntityException("bad state");
}
@GetMapping("/re/void")
public void voidWithResponseEntityException() {
throw new HandledResponseEntityException("bad state");
}
@GetMapping("/re/void/xml")
public void voidWithResponseEntityExceptionAsXml() {
throw new HandledResponseEntityException("bad state", MediaType.APPLICATION_XML);
}
@GetMapping("/pojo/re")View on GitHub (pinned to e1c734241f)
Solutions
- Expect the mapped error response (check status/body in tests) — do not try to avoid the throw on this endpoint
- Ensure an exception mapper for HandledResponseEntityException is registered if you get a raw 500 instead
- Keep thrown messages stable ('bad state') as tests likely assert on them
Defensive patterns
Strategy: try-catch
Try / catch
Response resp = given().get("/exception/re/re");
if (resp.statusCode() >= 400) {
// mapped HandledResponseEntityException('bad state') response
} Prevention
- Verify a mapper for HandledResponseEntityException exists before shipping
- Assert both status and body message ('bad state') in integration tests
- Test exception handling for each return type: ResponseEntity, POJO, void
When it happens
Trigger: GET /exception/re/re — the method unconditionally throws HandledResponseEntityException; any invocation produces the mapped error response.
Common situations: Integration tests of Spring-Web compatibility exception handling; verifying that ResponseEntity-returning handlers get the mapped error body/status rather than a raw 500.
Related errors
- unhandled
- Cannot transform exception ${exception}
- Unable to locate proper constructor for dynamically register
- Expected a ClientInvocationBuilder
- Expected a ClientInvocationBuilder
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ff1f5a6f7933b7bd.
Report an issue: GitHub.