Return better messages for JSON errors in API. (#18367)

* Return better messages for JSON errors in API.

* Improving structure once again.

* Include more attributes in specialized error class.

* Adding license header.

* Adding changelog snippet.

* Handling missing target type.

* Including reference path if present.

* Fixing up changelog, adding upgrade notes.

* Adding test for JSON parsing error responses.

* Constructing reference path for missing required property.

* Handling JSON parsing error on root level.

* Consolidating `JacksonPropertyExceptionMapper` to handle invalid properties in a structured way.

* Adjusting test.
This commit is contained in:
Dennis Oelkers
2024-06-03 08:32:13 +02:00
committed by GitHub
parent 08bdfd6e9d
commit 9830372bbf
11 changed files with 305 additions and 77 deletions

View File

@@ -53,7 +53,6 @@ import org.graylog.security.certutil.CertConstants;
import org.graylog2.configuration.TLSProtocolsConfiguration;
import org.graylog2.plugin.inject.Graylog2Module;
import org.graylog2.rest.MoreMediaTypes;
import org.graylog2.shared.rest.exceptionmappers.JacksonPropertyExceptionMapper;
import org.graylog2.shared.rest.exceptionmappers.JsonProcessingExceptionMapper;
import org.graylog2.shared.security.tls.KeyStoreUtils;
import org.slf4j.Logger;
@@ -194,8 +193,7 @@ public class JerseyService extends AbstractIdleService {
.registerClasses(
JacksonXmlBindJsonProvider.class,
JsonProcessingExceptionMapper.class,
JsonMappingExceptionMapper.class,
JacksonPropertyExceptionMapper.class)
JsonMappingExceptionMapper.class)
// Replacing this with a lambda leads to missing subtypes - https://github.com/Graylog2/graylog2-server/pull/10617#discussion_r630236360
.register(new ContextResolver<ObjectMapper>() {
@Override