World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#14861] fix(fileset): Stop exposing configuration in FileSystem creation errors (#14863)
Rimaz Saththar5c93edcbc7a6
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.javaindex ce3258cf00..9f9d16efe6 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@@ -1471,7 +1471,7 @@ public class FilesetCatalogOperations extends ManagedSchemaOperationsreturn getFileSystem(path, conf);} catch (IOException e) {throw new GravitinoRuntimeException(- e, "Failed to get FileSystem for fileset: path: %s, conf: %s", path, conf);+ e, "Failed to get FileSystem for fileset: path: %s", path);}});}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.javaindex c196464a07..0ab729bc75 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@@ -3902,6 +3902,36 @@ public class TestFilesetCatalogOperations {}}+ @Test+ void testGetFileSystemWithCacheErrorDoesNotExposeConfiguration() throws IOException {+ String catalogPath = TEST_ROOT_PATH + "/catalog_fs_error_" + generateTestId();+ Path path = new Path(catalogPath);+ Map<String, String> conf =+ ImmutableMap.of(+ "s3-access-key-id", "DUMMY_ACCESS_KEY_ID",+ "s3-secret-access-key", "DUMMY_SECRET_ACCESS_KEY");+ IOException cause = new IOException("Failed to create file system");++ try (FilesetCatalogOperations ops =+ Mockito.spy(new FilesetCatalogOperations(store, secretManager))) {+ ops.initialize(+ ImmutableMap.of(LOCATION, catalogPath),+ randomCatalogInfo("m1", "c1"),+ FILESET_PROPERTIES_METADATA);+ ops.fileSystemCache.invalidateAll();+ Mockito.doThrow(cause).when(ops).getFileSystem(Mockito.eq(path), Mockito.eq(conf));++ GravitinoRuntimeException e =+ Assertions.assertThrows(+ GravitinoRuntimeException.class, () -> ops.getFileSystemWithCache(path, conf));++ Assertions.assertSame(cause, e.getCause());+ Assertions.assertTrue(e.getMessage().contains(catalogPath));+ Assertions.assertFalse(e.getMessage().contains("DUMMY_ACCESS_KEY_ID"));+ Assertions.assertFalse(e.getMessage().contains("DUMMY_SECRET_ACCESS_KEY"));+ }+ }+private static Stream<Arguments> multipleLocationsArguments() {return Stream.of(// Honor the catalog location