Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Column-lineage endpoints supports point-in-time requests [`#2265`](https://github.com/MarquezProject/marquez/pull/2265) [@pawel-big-lebowski](https://github.com/pawel-big-lebowski)
*Enable requesting `column-lineage` endpoint by a dataset version, job version or dataset field of a specific dataset version.*

* Include error message for JSON processing exception [`#2271`](https://github.com/MarquezProject/marquez/pull/2271) [@pawel-big-lebowski](https://github.com/pawel-big-lebowski)
*In case of JSON processing exceptions Marquez API should return exception message to a client.*

## [0.28.0](https://github.com/MarquezProject/marquez/compare/0.27.0...0.28.0) - 2022-11-21

### Added
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/marquez/MarquezContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import marquez.api.SourceResource;
import marquez.api.TagResource;
import marquez.api.exceptions.JdbiExceptionExceptionMapper;
import marquez.api.exceptions.JsonProcessingExceptionMapper;
import marquez.db.BaseDao;
import marquez.db.ColumnLineageDao;
import marquez.db.DatasetDao;
Expand Down Expand Up @@ -96,6 +97,7 @@ public final class MarquezContext {
@Getter private final SearchResource searchResource;
@Getter private final ImmutableList<Object> resources;
@Getter private final JdbiExceptionExceptionMapper jdbiException;
@Getter private final JsonProcessingExceptionMapper jsonException;
@Getter private final GraphQLHttpServlet graphqlServlet;

private MarquezContext(
Expand Down Expand Up @@ -137,6 +139,7 @@ private MarquezContext(
this.lineageService = new LineageService(lineageDao, jobDao);
this.columnLineageService = new ColumnLineageService(columnLineageDao, datasetFieldDao);
this.jdbiException = new JdbiExceptionExceptionMapper();
this.jsonException = new JsonProcessingExceptionMapper();
final ServiceFactory serviceFactory =
ServiceFactory.builder()
.datasetService(datasetService)
Expand Down Expand Up @@ -169,6 +172,7 @@ private MarquezContext(
jobResource,
tagResource,
jdbiException,
jsonException,
openLineageResource,
searchResource);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2018-2022 contributors to the Marquez project
* SPDX-License-Identifier: Apache-2.0
*/

package marquez.api.exceptions;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.dropwizard.jersey.errors.ErrorMessage;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class JsonProcessingExceptionMapper implements ExceptionMapper<JsonProcessingException> {

@Override
public Response toResponse(JsonProcessingException e) {
log.error("Failed to process JSON", e);
return Response.serverError()
.type(APPLICATION_JSON_TYPE)
.entity(new ErrorMessage(BAD_REQUEST.getStatusCode(), e.getMessage()))
.build();
}
}
19 changes: 19 additions & 0 deletions api/src/test/java/marquez/OpenLineageIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,25 @@ public void testSendOpenLineageEventFailsValidation(String eventBody) throws IOE
assertThat(resp.join()).isEqualTo(422);
}

@Test
public void testSendOpenLineageEventFailsJsonProcessing() throws IOException {
String eventWithIncorrectEventTimeFormat =
"{\"eventTime\": \"2021-11-03\", \"eventType\": \"START\", \"inputs\": [], \"job\": {\"facets\": {}, \"name\": \"job\", \"namespace\": \"openlineage\"}, \"outputs\": [], \"run\": {\"facets\": {}, \"runId\": \"123e4567-e89b-12d3-a456-426614174000\"}}";

final CompletableFuture<String> resp =
this.sendLineage(eventWithIncorrectEventTimeFormat)
.thenApply(HttpResponse::body)
.whenComplete(
(val, err) -> {
if (err != null) {
Assertions.fail("Could not complete request");
}
});
assertThat(resp.join())
.contains(
"Cannot deserialize value of type `java.time.ZonedDateTime` from String \\\"2021-11-03\\\"");
}

@Test
public void testGetLineageForNonExistantDataset() {
CompletableFuture<Integer> response =
Expand Down