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

Improve error message for unsupported protobuf version #24

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/main/java/ai/spice/SpiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public FlightStream query(String sql) throws ExecutionException {
} catch (RetryException e) {
Throwable err = e.getLastFailedAttempt().getExceptionCause();
throw new ExecutionException("Failed to execute query due to error: " + err.toString(), err);
} catch (ExecutionException e) {
if (isUnsupportedProtobufVersionException(e.getCause())) {
throw new ExecutionException("Unsupported protobuf version has been detected. Please upgrade 'com.google.protobuf' dependency to version 3.25.x or later.", e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should note which version was detected.

}
throw e;
}
}

Expand Down Expand Up @@ -213,4 +218,12 @@ private boolean shouldRetry(CallStatus status) {
public void close() throws Exception {
this.flightClient.close();
}

private boolean isUnsupportedProtobufVersionException(Throwable cause) {
if (cause instanceof ArrayIndexOutOfBoundsException) {
String message = cause.getMessage();
return message != null && message.contains("Index 2 out of bounds for length 2");
}
return false;
}
}