Skip to content

Commit

Permalink
trino request handler fix for exception message length (#211)
Browse files Browse the repository at this point in the history
* truncate Trino query error message to 2K

* fix vulnerabilities

* handle indexOutOfBoundsException

* use StringUtils
  • Loading branch information
satish-mittal committed Oct 26, 2023
1 parent 40fc51e commit 0204dde
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Optional;
import java.util.Set;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.hypertrace.core.query.service.ExecutionContext;
import org.hypertrace.core.query.service.QueryCost;
import org.hypertrace.core.query.service.RequestHandler;
Expand Down Expand Up @@ -130,8 +131,7 @@ public Observable<Row> handleRequest(QueryRequest request, ExecutionContext exec

return executeQuery(sql.getKey(), sql.getValue());
} catch (Throwable t) {
String truncatedMessage = (t.getMessage() == null) ? null : t.getMessage().substring(0, 2048);
return Observable.error(new Throwable(truncatedMessage));
return Observable.error(new Throwable(StringUtils.truncate(t.getMessage(), 2048)));
}
}

Expand Down

0 comments on commit 0204dde

Please sign in to comment.