You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by ad...@apache.org on 2025/01/16 15:11:05 UTC
(polaris) 01/01: Throw NotAuthorizedException when realm is unknown
This is an automated email from the ASF dual-hosted git repository.
adutra pushed a commit to branch realm-throw-unauthorized
in repository https://gitbox.apache.org/repos/asf/polaris.git
commit ac723e79b898f142492a5c13274346067ac0910a
Author: Alexandre Dutra <ad...@users.noreply.github.com>
AuthorDate: Thu Jan 16 16:10:54 2025 +0100
Throw NotAuthorizedException when realm is unknown
Throwing IllegalArgumentException, as before, translates
into HTTP 500, which is not great.
---
.../org/apache/polaris/service/context/DefaultRealmIdResolver.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/service/common/src/main/java/org/apache/polaris/service/context/DefaultRealmIdResolver.java b/service/common/src/main/java/org/apache/polaris/service/context/DefaultRealmIdResolver.java
index 7e6a3b42..5e1573f8 100644
--- a/service/common/src/main/java/org/apache/polaris/service/context/DefaultRealmIdResolver.java
+++ b/service/common/src/main/java/org/apache/polaris/service/context/DefaultRealmIdResolver.java
@@ -22,6 +22,7 @@ import io.smallrye.common.annotation.Identifier;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.Map;
+import org.apache.iceberg.exceptions.NotAuthorizedException;
import org.apache.polaris.core.context.RealmId;
@ApplicationScoped
@@ -44,7 +45,7 @@ public class DefaultRealmIdResolver implements RealmIdResolver {
if (headers.containsKey(configuration.headerName())) {
realm = headers.get(configuration.headerName());
if (!configuration.realms().contains(realm)) {
- throw new IllegalArgumentException("Unknown realm: " + realm);
+ throw new NotAuthorizedException("Unknown realm: " + realm);
}
} else {
realm = configuration.defaultRealm();