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/28 13:28:43 UTC
(polaris) branch main updated: Map MSAL service exception status codes (#5605)
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 09840add8c Map MSAL service exception status codes (#5605)
09840add8c is described below
commit 09840add8cca27f60b5818337c22361aaf605ea5
Author: fivetran-ashokborra <12...@users.noreply.github.com>
AuthorDate: Mon Sep 28 18:58:37 2026 +0530
Map MSAL service exception status codes (#5605)
* Handle MSAL service exception status codes
* Simplify MSAL exception message assertion
* Handle nullable MSAL status codes
---
CHANGELOG.md | 3 +++
gradle/libs.versions.toml | 1 +
runtime/service/build.gradle.kts | 1 +
.../service/exception/IcebergExceptionMapper.java | 4 ++++
.../exception/IcebergExceptionMapperTest.java | 23 +++++++++++++++++++++-
5 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a0f1895d7a..e6934a1a5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -115,6 +115,9 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
### Changes
+- Azure credential vending now maps MSAL authentication failures using their HTTP status codes,
+ including the existing `401` to `403` and `404` to `400` mappings.
+
- A metastore failure during authentication now returns a fixed `Service unavailable` message
instead of naming the lookup that failed; the principal lookup previously returned `Unable to
fetch principal entity`. The failing lookup is still named in the server log at `ERROR`, which
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index ddcefd7b8f..f8460fe8a1 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -96,6 +96,7 @@ microprofile-fault-tolerance-api = { module = "org.eclipse.microprofile.fault-to
mockito-core = { module = "org.mockito:mockito-core", version = "5.24.0" }
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version = "5.24.0" }
mongodb-driver-sync = { module = "org.mongodb:mongodb-driver-sync", version = "5.13.0" }
+msal4j = { module = "com.microsoft.azure:msal4j", version = "1.23.1" }
openlineage-java = { module = "io.openlineage:openlineage-java", version = "1.53.0" }
opentelemetry-instrumentation-bom-alpha = { module = "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha", version= "2.20.1-alpha" }
picocli = { module = "info.picocli:picocli-codegen", version.ref = "picocli" }
diff --git a/runtime/service/build.gradle.kts b/runtime/service/build.gradle.kts
index f986d31525..a77ae2b228 100644
--- a/runtime/service/build.gradle.kts
+++ b/runtime/service/build.gradle.kts
@@ -105,6 +105,7 @@ dependencies {
implementation("com.azure:azure-core")
implementation("com.azure:azure-storage-blob")
implementation("com.azure:azure-storage-file-datalake")
+ implementation(libs.msal4j)
compileOnly(libs.swagger.annotations)
diff --git a/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java b/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
index 60f4f665ce..397e6dc0f0 100644
--- a/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
+++ b/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
@@ -25,6 +25,7 @@ import com.google.cloud.storage.StorageException;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
+import com.microsoft.aad.msal4j.MsalServiceException;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@@ -212,6 +213,8 @@ public class IcebergExceptionMapper implements ExceptionMapper<RuntimeException>
public static int extractHttpCodeFromCloudException(Throwable t) {
return switch (t) {
case S3Exception s3e -> s3e.statusCode();
+ case MsalServiceException mse ->
+ Optional.ofNullable(mse.statusCode()).orElse(UNKNOWN_CLOUD_HTTP_CODE);
case StsException stse -> stse.statusCode();
case HttpResponseException hre -> hre.getResponse().getStatusCode();
case StorageException se -> se.getCode();
@@ -228,6 +231,7 @@ public class IcebergExceptionMapper implements ExceptionMapper<RuntimeException>
*/
static Optional<Integer> mapCloudExceptionToResponseCode(Throwable t) {
if (!(t instanceof S3Exception
+ || t instanceof MsalServiceException
|| t instanceof StsException
|| t instanceof AzureException
|| t instanceof StorageException)) {
diff --git a/runtime/service/src/test/java/org/apache/polaris/service/exception/IcebergExceptionMapperTest.java b/runtime/service/src/test/java/org/apache/polaris/service/exception/IcebergExceptionMapperTest.java
index 3f5700461f..c5dd8db1c6 100644
--- a/runtime/service/src/test/java/org/apache/polaris/service/exception/IcebergExceptionMapperTest.java
+++ b/runtime/service/src/test/java/org/apache/polaris/service/exception/IcebergExceptionMapperTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import com.azure.core.exception.AzureException;
import com.azure.core.exception.HttpResponseException;
import com.google.cloud.storage.StorageException;
+import com.microsoft.aad.msal4j.MsalServiceException;
import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.net.UnknownHostException;
@@ -41,7 +42,6 @@ import software.amazon.awssdk.services.s3.model.S3Exception;
import software.amazon.awssdk.services.sts.model.StsException;
public class IcebergExceptionMapperTest {
-
static Stream<Arguments> fileIOExceptionMapping() {
Map<Integer, Integer> cloudCodeMappings =
Map.of(
@@ -99,6 +99,27 @@ public class IcebergExceptionMapperTest {
.statusCode(entry.getKey())
.build(),
entry.getValue()),
+ Arguments.of(
+ new MsalServiceException(
+ "AADSTS7000222: The provided client secret keys for app "
+ + "'abc12345-abcd-4abc-8abc-1234567890ab' are expired. "
+ + "Visit the Azure portal to create new keys for your "
+ + "app: https://aka.ms/NewClientSecret, or consider using "
+ + "certificate credentials for added security: "
+ + "https://aka.ms/certCreds. Trace ID: "
+ + "abc12345-abcd-4abc-8abc-1234567890ac Correlation ID: "
+ + "abc12345-abcd-4abc-8abc-1234567890ad Timestamp: "
+ + "2026-09-24 07:59:05Z",
+ "service_error") {
+ @Override
+ public Integer statusCode() {
+ return entry.getKey();
+ }
+ },
+ entry.getValue()),
+ Arguments.of(
+ new MsalServiceException("Authentication failed", "service_error"),
+ Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()),
Arguments.of(
StsException.builder()
.message("")