You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by di...@apache.org on 2026/09/16 20:38:05 UTC

(polaris) branch main updated: fix: clarify the error when X-Iceberg-Access-Delegation resolves to unsupported remote signing (#5473)

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

dimas-b pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 13ad6d95ba fix: clarify the error when X-Iceberg-Access-Delegation resolves to unsupported remote signing (#5473)
13ad6d95ba is described below

commit 13ad6d95ba090ba5daf02ac26e3114c7e3b9180e
Author: youngrae81 <16...@users.noreply.github.com>
AuthorDate: Thu Sep 17 05:38:00 2026 +0900

    fix: clarify the error when X-Iceberg-Access-Delegation resolves to unsupported remote signing (#5473)
    
    When the resolved mode is REMOTE_SIGNING, which is not implemented,
    the request now fails with `This catalog cannot vend credentials or
    sign requests; request without X-Iceberg-Access-Delegation and
    configure storage credentials on the client` instead of the opaque
    `Unsupported access delegation mode: REMOTE_SIGNING`.
    
    This applies to remote-signing alone as well, so the PR no longer changes behavior,
    only the error message.
---
 CHANGELOG.md                                       |  6 +++
 .../service/it/RestCatalogFlociS3SpecialIT.java    | 33 ++++++++++++++++
 .../catalog/iceberg/IcebergCatalogHandler.java     | 16 +++++---
 .../catalog/iceberg/IcebergCatalogHandlerTest.java | 45 ++++++++++++++++++++++
 4 files changed, 95 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d7b76e392..1ac318e4ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -123,6 +123,12 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
   `400 Bad Request` (`Invalid page token`) instead of `500 Internal Server Error`. Tokens that are
   valid Base64 but not a serialized page token (garbage, truncated, or produced by an incompatible
   Polaris version) previously escaped as Jackson decoding exceptions.
+- Iceberg REST: when `X-Iceberg-Access-Delegation` resolves to remote signing (not implemented),
+  either because `remote-signing` was requested alone or because `vended-credentials,remote-signing`
+  was requested against a catalog that cannot vend credentials, the `400` response now explains the
+  situation and what to do (`This catalog cannot vend credentials or sign requests; request without
+  X-Iceberg-Access-Delegation and configure storage credentials on the client`) instead of the opaque
+  `Unsupported access delegation mode: REMOTE_SIGNING`.
 - Iceberg REST: renaming a table or view with a missing `source` or `destination` now returns `400 Bad Request` instead of `500 Internal Server Error`.
 - Async file-cleanup tasks now bound how long they wait for object-store deletions via the new `polaris.tasks.file-deletion-timeout` (default 1h), so a stalled storage endpoint can no longer pin a task-executor thread indefinitely; a timeout is terminal for the current run rather than immediately retried, so it does not stack more deletions onto the stalled endpoint.
 - Python CLI `catalogs create --type external` now validates `--storage-type` and `--default-base-location` up front, matching the behavior for internal catalogs and the flags' documented "(Required)" status. Previously, omitting either produced an opaque pydantic `ValidationError` at request-build time.
diff --git a/runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogFlociS3SpecialIT.java b/runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogFlociS3SpecialIT.java
index 563986aee4..f7d0904ad5 100644
--- a/runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogFlociS3SpecialIT.java
+++ b/runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogFlociS3SpecialIT.java
@@ -200,6 +200,39 @@ public class RestCatalogFlociS3SpecialIT extends AbstractRestCatalogFlociS3Speci
     }
   }
 
+  /**
+   * A request that resolves to remote signing (not implemented) against a catalog that cannot vend
+   * credentials fails fast with a message telling the client what to do, instead of the opaque
+   * "Unsupported access delegation mode: REMOTE_SIGNING".
+   */
+  @ParameterizedTest
+  @ValueSource(strings = {"vended-credentials,remote-signing", "remote-signing"})
+  public void testLoadTableWithRemoteSigningRequestedWithoutStsFailsWithActionableMessage(
+      String accessDelegationHeader) throws IOException {
+    try (var restCatalog =
+        createCatalog(
+            Optional.of(endpoint),
+            Optional.of("http://sts.example.com"),
+            true,
+            Optional.empty(),
+            false)) {
+
+      catalogApi.createNamespace(catalogName, "test-ns");
+      var id = TableIdentifier.of("test-ns", "t4");
+      restCatalog.createTable(id, SCHEMA);
+
+      assertThatThrownBy(
+              () ->
+                  catalogApi.loadTable(
+                      catalogName,
+                      id,
+                      "ALL",
+                      Map.of("X-Iceberg-Access-Delegation", accessDelegationHeader)))
+          .hasMessageContaining("This catalog cannot vend credentials or sign requests")
+          .hasMessageContaining("request without X-Iceberg-Access-Delegation");
+    }
+  }
+
   @Test
   public void testLoadTableFailureWithCredentialVendingWithoutSts() throws IOException {
     try (var restCatalog =
diff --git a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
index 19a32fe1e0..b97e9aed0c 100644
--- a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
+++ b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
@@ -1798,6 +1798,12 @@ public abstract class IcebergCatalogHandler extends CatalogHandler implements Au
    * Resolves the access delegation mode by delegating to the configured {@link
    * AccessDelegationModeResolver}.
    *
+   * <p>Remote signing is not implemented yet. Whenever the resolver settles on {@link
+   * AccessDelegationMode#REMOTE_SIGNING}, either because the client asked for it alone or because
+   * credential vending is not possible for the catalog and the client offered remote signing as the
+   * alternative, the request fails fast with a message that tells the client what to do. This
+   * matches how a vended-credentials-only request behaves when no credentials can be vended.
+   *
    * @param requestedModes The non-empty set of delegation modes requested by the client
    * @return The resolved access delegation mode, or empty if no delegation mode was resolved
    */
@@ -1809,11 +1815,11 @@ public abstract class IcebergCatalogHandler extends CatalogHandler implements Au
         accessDelegationModeResolver().resolve(requestedModes, catalogEntity);
 
     // TODO remove when remote signing is implemented
-    // Reject if the resolved mode is REMOTE_SIGNING since it's not yet supported
-    Preconditions.checkArgument(
-        resolvedMode.orElse(null) != AccessDelegationMode.REMOTE_SIGNING,
-        "Unsupported access delegation mode: %s",
-        AccessDelegationMode.REMOTE_SIGNING);
+    if (resolvedMode.orElse(null) == AccessDelegationMode.REMOTE_SIGNING) {
+      throw new IllegalArgumentException(
+          "This catalog cannot vend credentials or sign requests; request without "
+              + "X-Iceberg-Access-Delegation and configure storage credentials on the client");
+    }
 
     return resolvedMode;
   }
diff --git a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerTest.java b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerTest.java
index 6d727bd085..9eb4ad96c3 100644
--- a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerTest.java
+++ b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.polaris.service.catalog.iceberg;
 
+import static org.apache.polaris.service.catalog.AccessDelegationMode.REMOTE_SIGNING;
 import static org.apache.polaris.service.catalog.AccessDelegationMode.VENDED_CREDENTIALS;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
@@ -89,6 +90,7 @@ import org.apache.polaris.core.persistence.resolver.ResolvedPathKey;
 import org.apache.polaris.core.persistence.resolver.ResolverFactory;
 import org.apache.polaris.core.storage.PolarisStorageActions;
 import org.apache.polaris.core.storage.StorageAccessConfig;
+import org.apache.polaris.service.catalog.AccessDelegationMode;
 import org.apache.polaris.service.catalog.AccessDelegationModeResolver;
 import org.apache.polaris.service.catalog.CatalogPrefixParser;
 import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
@@ -232,6 +234,49 @@ class IcebergCatalogHandlerTest {
     assertThat(actionsCaptor.getValue()).containsExactlyInAnyOrder(actions);
   }
 
+  /**
+   * When the resolver degrades a both-modes request to {@link AccessDelegationMode#REMOTE_SIGNING}
+   * (credential vending is not possible for the catalog) and remote signing is not implemented, the
+   * request fails fast with a message that tells the client what to do, matching how a
+   * vended-credentials-only request already behaves in that situation.
+   */
+  @Test
+  void bothModesRequestedAndResolverDegradesToRemoteSigningFailsWithActionableMessage() {
+    mockRegisterTableCatalog(false);
+    EnumSet<AccessDelegationMode> bothModes = EnumSet.of(VENDED_CREDENTIALS, REMOTE_SIGNING);
+    when(accessDelegationModeResolver.resolve(eq(bothModes), any()))
+        .thenReturn(Optional.of(REMOTE_SIGNING));
+
+    @SuppressWarnings("resource")
+    IcebergCatalogHandler handler = newHandler();
+
+    assertThatThrownBy(
+            () ->
+                handler.registerTable(
+                    NS1, registerTableRequest(false), bothModes, Optional.empty()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageContaining("This catalog cannot vend credentials or sign requests")
+        .hasMessageContaining("request without X-Iceberg-Access-Delegation");
+  }
+
+  @Test
+  void remoteSigningRequestedAloneFailsWithActionableMessage() {
+    mockRegisterTableCatalog(false);
+    EnumSet<AccessDelegationMode> remoteSigningOnly = EnumSet.of(REMOTE_SIGNING);
+    when(accessDelegationModeResolver.resolve(eq(remoteSigningOnly), any()))
+        .thenReturn(Optional.of(REMOTE_SIGNING));
+
+    @SuppressWarnings("resource")
+    IcebergCatalogHandler handler = newHandler();
+
+    assertThatThrownBy(
+            () ->
+                handler.registerTable(
+                    NS1, registerTableRequest(false), remoteSigningOnly, Optional.empty()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageContaining("This catalog cannot vend credentials or sign requests");
+  }
+
   @Test
   void registerTableWithVendedCredentialsVendsReadWriteActionsWhenWriteDelegationAuthorized() {
     Catalog catalog = mockRegisterTableCatalog(false);