This is an automated email from the ASF dual-hosted git repository.
mchades 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 5c93edcbc7 [#14861] fix(fileset): Stop exposing configuration in
FileSystem creation errors (#14863)
5c93edcbc7 is described below
commit 5c93edcbc7a65f0b9358fbe91859125dddf984b9
Author: Rimaz Saththar <[email protected]>
AuthorDate: Wed Nov 11 09:29:44 2026 +0530
[#14861] fix(fileset): Stop exposing configuration in FileSystem creation
errors (#14863)
### What changes were proposed in this pull request?
Remove the configuration map from the `GravitinoRuntimeException`
message thrown by `FilesetCatalogOperations.getFileSystemWithCache()`
when creating a `FileSystem` fails. The message keeps the path, and the
original `IOException` is still attached as the cause.
### Why are the changes needed?
The configuration can contain plaintext credentials such as
`s3-secret-access-key`. Including the whole map in the exception message
meant that any caller logging the exception also logged those
credentials. This is the same kind of fix as #14344.
Fixes #14861
### Does this PR introduce _any_ user-facing change?
The error message no longer includes configuration values. It now reads
`Failed to get FileSystem for fileset: path: <path>`.
### How was this patch tested?
Added
`TestFilesetCatalogOperations#testGetFileSystemWithCacheErrorDoesNotExposeConfiguration`.
It makes `getFileSystem()` throw an `IOException` for a configuration
with dummy `s3-access-key-id` / `s3-secret-access-key` values, then
checks that the exception keeps the original cause and the path, and
that neither dummy value appears in the message. The test fails without
the change.
Ran `./gradlew :catalogs:catalog-fileset:build -PskipITs
-PskipDockerTests=true -PskipWeb=true` locally (spotless, checkstyle and
all catalog-fileset unit tests pass).
---
.../catalog/fileset/FilesetCatalogOperations.java | 2 +-
.../fileset/TestFilesetCatalogOperations.java | 30 ++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
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 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
ManagedSchemaOperations
return 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.java
index 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