Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SentryJobErrorReporter: better handling of multiline chained java exceptions #14398

Merged
merged 1 commit into from
Jul 5, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ private static Optional<List<SentryException>> buildJavaSentryExceptions(final S
final List<SentryException> sentryExceptions = new ArrayList<>();

// separate chained exceptions
// e.g "\nCaused By: "
final String exceptionSeparator = "\n[\\w ]+: ";
// e.g "\nCaused by: "
final String exceptionSeparator = "\nCaused by: ";
final String[] exceptions = stacktrace.split(exceptionSeparator);

for (final String exceptionStr : exceptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,38 @@ void testBuildSentryExceptionsJavaMultilineValue() {
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
... 22 more
Caused by: org.postgresql.util.PSQLException: ERROR: publication "airbyte_publication" does not exist
Where: slot "airbyte_slot", output plugin "pgoutput", in the change callback, associated LSN 0/48029520
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)
""";

final Optional<List<SentryException>> optionalSentryExceptions = exceptionHelper.buildSentryExceptions(stacktrace);
Assertions.assertTrue(optionalSentryExceptions.isPresent());
final List<SentryException> exceptionList = optionalSentryExceptions.get();
Assertions.assertEquals(1, exceptionList.size());
Assertions.assertEquals(2, exceptionList.size());

final String expectedValue =
assertExceptionContent(exceptionList.get(0), "io.temporal.failure.ApplicationFailure",
"""
GET https://storage.googleapis.com/
{
"code" : 401,
"message" : "Invalid Credentials"
}""";

assertExceptionContent(exceptionList.get(0), "io.temporal.failure.ApplicationFailure",
expectedValue, List.of(
}""", List.of(
Map.of(
"filename", "GoogleJsonResponseException.java",
"lineno", 146,
"module", "com.google.api.client.googleapis.json.GoogleJsonResponseException",
"function", "from")));

assertExceptionContent(exceptionList.get(1), "org.postgresql.util.PSQLException",
"""
ERROR: publication "airbyte_publication" does not exist
Where: slot "airbyte_slot", output plugin "pgoutput", in the change callback, associated LSN 0/48029520""", List.of(
Map.of(
"filename", "QueryExecutorImpl.java",
"lineno", 2675,
"module", "org.postgresql.core.v3.QueryExecutorImpl",
"function", "receiveErrorResponse")));
}

private void assertExceptionContent(final SentryException exception,
Expand Down