This is an automated email from the ASF dual-hosted git repository.

dweeks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/main by this push:
     new 1a4f23bc0e Core: Fix REST catalog handling when the service has no 
view support (#9853)
1a4f23bc0e is described below

commit 1a4f23bc0e6cda520ca815f2a245f5f21bfbc24f
Author: Ryan Blue <[email protected]>
AuthorDate: Sat Mar 2 14:05:42 2024 -0800

    Core: Fix REST catalog handling when the service has no view support (#9853)
    
    * Core: Fix REST catalog handling when the service has no view support.
    
    * Fix error message.
    
    * Improve the error message.
---
 .../apache/iceberg/rest/RESTSessionCatalog.java    | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java 
b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
index 742caa9494..a34f738c31 100644
--- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
@@ -1058,12 +1058,22 @@ public class RESTSessionCatalog extends 
BaseViewSessionCatalog
   public View loadView(SessionContext context, TableIdentifier identifier) {
     checkViewIdentifierIsValid(identifier);
 
-    LoadViewResponse response =
-        client.get(
-            paths.view(identifier),
-            LoadViewResponse.class,
-            headers(context),
-            ErrorHandlers.viewErrorHandler());
+    LoadViewResponse response;
+    try {
+      response =
+          client.get(
+              paths.view(identifier),
+              LoadViewResponse.class,
+              headers(context),
+              ErrorHandlers.viewErrorHandler());
+    } catch (UnsupportedOperationException | RESTException e) {
+      // Normally, copying an exception message is a bad practice but engines 
may show just the
+      // message and suppress the exception cause when the view does not 
exist. Since 401 and 403
+      // responses can trigger this case, including the message increases the 
chances that the "Not
+      // authorized" or "Forbidden" message is preserved and shown.
+      throw new NoSuchViewException(
+          e, "Unable to load view %s.%s: %s", name(), identifier, 
e.getMessage());
+    }
 
     AuthSession session = tableSession(response.config(), session(context));
     ViewMetadata metadata = response.metadata();

Reply via email to