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

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


The following commit(s) were added to refs/heads/main by this push:
     new aab6a66ace [#14844] fix(fileset): Return connection failures for named 
location checks (#14885)
aab6a66ace is described below

commit aab6a66acec2a16e2f06d51ac820b4970fcacd5c
Author: mchades <[email protected]>
AuthorDate: Wed Nov 11 16:00:37 2026 +0800

    [#14844] fix(fileset): Return connection failures for named location checks 
(#14885)
    
    ### What changes were proposed in this pull request?
    
    Classify I/O errors from `exists()` and `getFileStatus()` on named
    Fileset locations as `ConnectionFailedException`. Return the location
    name and failure category, and log the backend exception on the server.
    
    ### Why are the changes needed?
    
    An S3 access denial during initialization currently returns HTTP 500
    with code 1002 before the connection probe runs.
    
    Fixes #14844. See also #14867.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. For a denied S3 location, `testConnection` returns HTTP 200 with
    code 1007 and identifies the failure as `location-s3 (access denied)`.
    
    ### How was this patch tested?
    
    - Added regression cases for access denied in both filesystem calls.
    - Verified the REST handlers for proposed and existing catalogs against
    a local S3 endpoint returning 403.
    - Ran the full Gradle unit suite (`test -PskipITs`) with a temporary
    hosts file for the Java client test JVM.
---
 .../catalog/fileset/FilesetCatalogOperations.java  | 11 ++++++--
 .../fileset/TestFilesetCatalogOperations.java      | 33 ++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git 
a/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
 
b/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
index 9f9d16efe6..7da3a90b99 100644
--- 
a/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
+++ 
b/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
@@ -1202,8 +1202,15 @@ public class FilesetCatalogOperations extends 
ManagedSchemaOperations
                           + locationName);
                 }
               } catch (IOException e) {
-                throw ExceptionMessages.wrap(
-                    "Failed to check if fileset catalog location exists: " + 
v, e);
+                // REST responses can include the cause chain. Keep backend 
diagnostics in the log.
+                LOG.warn(
+                    "Failed to check {} for Fileset catalog {}.{}",
+                    k,
+                    catalogInfo.namespace(),
+                    catalogInfo.name(),
+                    e);
+                throw new ConnectionFailedException(
+                    "Failed to check Fileset catalog storage at %s (%s)", k, 
failureCategory(e));
               }
             }
 
diff --git 
a/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
 
b/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
index 0ab729bc75..dca9a991f4 100644
--- 
a/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
+++ 
b/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
@@ -2600,6 +2600,39 @@ public class TestFilesetCatalogOperations {
     }
   }
 
+  @ParameterizedTest
+  @ValueSource(booleans = {true, false})
+  void testInitializeReportsNamedLocationAccessDenied(boolean failOnExists) 
throws IOException {
+    Path path = new Path("s3a://test-bucket/private-prefix");
+    FileSystem fileSystem = Mockito.mock(FileSystem.class);
+    AccessDeniedException denied =
+        new AccessDeniedException(path.toString(), null, "backend request ID");
+    if (failOnExists) {
+      when(fileSystem.exists(path)).thenThrow(denied);
+    } else {
+      when(fileSystem.exists(path)).thenReturn(true);
+      when(fileSystem.getFileStatus(path)).thenThrow(denied);
+    }
+
+    try (FilesetCatalogOperations ops =
+        Mockito.spy(new FilesetCatalogOperations(store, secretManager))) {
+      doReturn(fileSystem).when(ops).getFileSystem(Mockito.eq(path), 
Mockito.anyMap());
+      ConnectionFailedException failure =
+          Assertions.assertThrows(
+              ConnectionFailedException.class,
+              () ->
+                  ops.initialize(
+                      ImmutableMap.of(PROPERTY_MULTIPLE_LOCATIONS_PREFIX + 
"s3", path.toString()),
+                      randomCatalogInfo("metalake", "catalog"),
+                      FILESET_PROPERTIES_METADATA));
+
+      Assertions.assertEquals(
+          "Failed to check Fileset catalog storage at location-s3 (access 
denied)",
+          failure.getMessage());
+      Assertions.assertNull(failure.getCause());
+    }
+  }
+
   @Test
   public void testTestConnectionRejectsDefaultCatalogLocationThatIsAFile() 
throws IOException {
     File fileLocation = new File(UNFORMALIZED_TEST_ROOT_PATH, 
"connection/default-file-location");

Reply via email to