dimas-b commented on code in PR #864:
URL: https://github.com/apache/polaris/pull/864#discussion_r1929218300
##########
service/common/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java:
##########
@@ -144,4 +112,56 @@ public static boolean containsAnyAccessDeniedHint(String
message) {
public static Collection<String> getAccessDeniedHints() {
return ImmutableSet.copyOf(ACCESS_DENIED_HINTS);
}
+
+ static int mapExceptionToResponseCode(RuntimeException rex) {
+ // Cloud exceptions
+ if (rex instanceof S3Exception
+ || rex instanceof AzureException
+ || rex instanceof StorageException) {
+ if (doesAnyThrowableContainAccessDeniedHint(rex)) {
+ return Response.Status.FORBIDDEN.getStatusCode();
+ }
+
+ int httpCode =
+ switch (rex) {
+ case S3Exception s3e -> s3e.statusCode();
+ case HttpResponseException hre ->
hre.getResponse().getStatusCode();
+ case StorageException se -> se.getCode();
+ default -> -1;
+ };
+
+ if (300 <= httpCode && httpCode <= 499) {
+ return httpCode;
Review Comment:
> Cloud Storage can return 3xx when the region is set incorrectly, the path
is invalid, and when files are moved. [...]
Interesting :thinking: Still, the response here goes to the Catalog client.
This client is most cases is not involved in configuring the catalog. Why
should it get a 3xx or 4xx error?
For a 4xx error the server ought to prove that the client's request is "bad"
is some sense, but here the error is not in the request, but in the
configuration owned by the server.
A 3xx response indicates the client should re-sent the request to a
different URL. Again, this does not make sense if the reason is catalog (mis-)
configuration.
If we want to distinguish these failures from "coding mistakes", I think a
502 (Bad Gateway) response may be appropriate from the HTTP perspective and
also provide input into finding the root cause. In this case, I think Polaris
should add its own message to the HTTP response to make it clear that it is
only propagating the storage error to the client.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]