Skip to content
Closed
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
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 @@ -51,4 +51,15 @@ 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.");
}
}
Loading