Skip to content

Commit

Permalink
[ISSUE] Error parsing Databricks Error databricks#260
Browse files Browse the repository at this point in the history
  • Loading branch information
Costin Chiulan committed Aug 6, 2024
1 parent 22e2561 commit abe83f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ErrorDetail(
this.type = type;
this.reason = reason;
this.domain = domain;
this.metadata = Collections.unmodifiableMap(metadata);
this.metadata = metadata != null ? Collections.unmodifiableMap(metadata) : null;
}

public String getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ void handleUnexpectedFieldsInErrorResponse() throws JsonProcessingException {
assertEquals(error.getErrorCode(), "theerrorcode");
assertEquals(error.getMessage(), "themessage");
}

@Test
void handleNullMetadataFieldInErrorResponse() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String rawResponse =
"{\"error_code\":\"METASTORE_DOES_NOT_EXIST\",\"message\":\"No metastore assigned for the current workspace.\",\"details\":[{\"@type\":\"type.googleapis.com/google.rpc.RequestInfo\",\"request_id\":\"1888e822-f1b5-4996-85eb-0d2b5cc402e6\",\"serving_data\":\"\"}]}";
ApiErrorBody error = mapper.readValue(rawResponse, ApiErrorBody.class);

assertEquals(error.getErrorCode(), "METASTORE_DOES_NOT_EXIST");
assertEquals(error.getMessage(), "No metastore assigned for the current workspace.");
}

}

0 comments on commit abe83f8

Please sign in to comment.