quarkiverse / quarkus-resteasy-problem

Unified error responses for Quarkus REST APIs via Problem Details for HTTP APIs (RFC9457 & RFC7807)
https://docs.quarkiverse.io/quarkus-resteasy-problem/dev
Apache License 2.0
69 stars 12 forks source link

Add mapper for jackson `com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException` #72

Closed lwitkowski closed 3 years ago

lwitkowski commented 3 years ago

Is your feature request related to RFC7807? Please describe. Quarkus provides custom exception mapper for this exception, and client gets 'test/html' response: org.jboss.resteasy.plugins.providers.jackson.UnrecognizedPropertyExceptionHandler

This exception is thrown when request payload json does not fit DTO object with @Valid annotation (e.g field has different name) and FAIL_ON_UNKNOWN_PROPERTIES is enabled (default changed in quarkus 1.11)

Describe the solution you'd like UnrecognizedPropertyException should be mapped to application/problem+json.

lwitkowski commented 3 years ago

I've just scanned main branch (few days old) of quarkus codebase, and found more Exception Mappers that we should consider overriding:

io.quarkus.hibernate.validator.runtime.jaxrs.QuarkusRestViolationExceptionMapper implements ExceptionMapper<ValidationException>
io.quarkus.hibernate.validator.runtime.jaxrs.ResteasyViolationExceptionMapper implements ExceptionMapper<ValidationException>
io.quarkus.hibernate.orm.rest.data.panache.runtime.RestDataPanacheExceptionMapper implements ExceptionMapper<RestDataPanacheException>
io.quarkus.mongodb.rest.data.panache.runtime.RestDataPanacheExceptionMapper implements ExceptionMapper<RestDataPanacheException>
io.quarkus.resteasy.reactive.server.runtime.exceptionmappers.AuthenticationCompletionExceptionMapper implements ExceptionMapper<AuthenticationCompletionException>
io.quarkus.resteasy.reactive.server.runtime.exceptionmappers.AuthenticationRedirectExceptionMapper implements ExceptionMapper<AuthenticationRedirectException>
io.quarkus.resteasy.runtime.AuthenticationCompletionExceptionMapper implements ExceptionMapper<AuthenticationCompletionException>
io.quarkus.resteasy.runtime.AuthenticationFailedExceptionMapper implements ExceptionMapper<AuthenticationFailedException>
io.quarkus.resteasy.runtime.AuthenticationRedirectExceptionMapper implements ExceptionMapper<AuthenticationRedirectException>
io.quarkus.resteasy.runtime.CompositeExceptionMapper implements ExceptionMapper<CompositeException>
io.quarkus.spring.data.rest.runtime.RestDataPanacheExceptionMapper implements ExceptionMapper<RestDataPanacheException>
io.quarkus.spring.web.runtime.ResponseStatusExceptionMapper implements ExceptionMapper<ResponseStatusException>