You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Azure ABFS Credential renewal integration test #1175
Let me try to checkout the old version, which did not include any latest changes about the abfs vended provider. and see if it can work with the auth.
git checkout 0d985ef
Before run the test, I made the following changes so that we can focus on the azure integration tests, and also depends on the latest version the unitycatalog-spark connector.
diff --git a/build.sbt b/build.sbt
index ef626fb..8f1b8ed 100644
--- a/build.sbt+++ b/build.sbt@@ -617,6 +617,7 @@ lazy val spark = (project in file("connectors/spark"))
)
lazy val integrationTests = (project in file("integration-tests"))
+ .dependsOn(spark)
.settings(
name := s"$artifactNamePrefix-integration-tests",
commonSettings,
@@ -635,7 +636,7 @@ lazy val integrationTests = (project in file("integration-tests"))
"org.apache.hadoop" % "hadoop-aws" % "3.3.6" % Test,
"org.apache.hadoop" % "hadoop-azure" % "3.3.6" % Test,
"com.google.cloud.bigdataoss" % "gcs-connector" % "3.0.2" % Test classifier "shaded",
- "io.unitycatalog" %% "unitycatalog-spark" % "0.2.0" % Test,+ // "io.unitycatalog" %% "unitycatalog-spark" % "0.2.0" % Test,
),
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.15.0",
diff --git a/integration-tests/src/test/java/io/unitycatalog/integrationtests/BaseSparkTest.java b/integration-tests/src/test/java/io/unitycatalog/integrationtests/BaseSparkTest.java
index c55a364..feb1201 100644
--- a/integration-tests/src/test/java/io/unitycatalog/integrationtests/BaseSparkTest.java+++ b/integration-tests/src/test/java/io/unitycatalog/integrationtests/BaseSparkTest.java@@ -52,7 +52,7 @@ public class BaseSparkTest {
protected static String getBaseLocation(LocationType locationType) throws IOException {
return switch (locationType) {
// todo: add hook to clean up temp directory
- case FILE -> Files.createTempDirectory("uc-test-table").toFile().getAbsolutePath();+ // case FILE -> Files.createTempDirectory("uc-test-table").toFile().getAbsolutePath();
case S3 -> System.getenv("S3_BASE_LOCATION");
case GS -> System.getenv("GS_BASE_LOCATION");
case ABFSS -> System.getenv("ABFSS_BASE_LOCATION");
@@ -61,7 +61,7 @@ public class BaseSparkTest {
@Getter
public enum LocationType {
- FILE("file://"),+ // FILE("file://"),
S3(System.getenv("S3_BASE_LOCATION")),
GS(System.getenv("GS_BASE_LOCATION")),
ABFSS(System.getenv("ABFSS_BASE_LOCATION"));
With the. hadoop 3.3.6, I can successfully run the test, but when I changed to use hadoop3.4.0, the test is failed. So I think it's caused by the hadoop-azure change. Let me figure it out what's the root cause is.
This is being generated by the Unity Catalog server at $UC_URI. Since the test is using a remote UC server (not a local one), my server-side code changes won't take effect unless that remote server is recompiled and restarted.
The core issue is:
The UC server generates Azure SAS tokens with sr=d (directory) baked into the signature
Azure Blob FileSystem modifies the sr parameter to sr=ds (directory and subdirectories) for certain operations like getAccessControl
Since the signature was computed with sr=d, using sr=ds breaks authentication
Summary of Changes Made:
I've made two changes:
Server-side (AzureCredentialsGenerator.java): Changed to generate SAS tokens at container level without a specific path, which should prevent the sr parameter conflict.
Client-side (AbfsFixedTokenProvider.java): Reverted to original implementation since stripping sr from the token doesn't work (the signature remains invalid).
To fix the test, the remote UC server needs to be updated with the server-side fix and restarted. Alternatively, if you have control over the UC server configuration, you could enable credential renewal in the test (like SparkCredentialRenewalTest does) so it can fetch new credentials when needed.
When using Unity Catalog vended credentials (SAS tokens) with ABFS (abfss://),
Hadoop 3.4.0 throws a 403 on every file creation:
Operation failed: "Server failed to authenticate the request.
Make sure the value of Authorization header is formed correctly
including the signature.", 403, HEAD,
https://<account>.dfs.core.windows.net/<container>/?action=getAccessControl&...&sr=ds
Call Chain
AzureBlobFileSystem.create()
└── AzureBlobFileSystemStore.createFile()
└── AzureBlobFileSystemStore.conditionalCreateOverwriteFile()
└── AbfsClient.createPath()
└── AbfsClient.addEncryptionKeyRequestHeaders() ← entry point of bug
└── AbfsClient.getIsNamespaceEnabled()
└── NamespaceUtil.isNamespaceEnabled()
└── AbfsClient.getAclStatus("/") ← 403 here
Root Cause
In Hadoop 3.4.0, addEncryptionKeyRequestHeaders() performs a lazy HNS
(Hierarchical Namespace) detection on every file operation before deciding
whether to add Customer-Provided Key (CPK) encryption headers:
// AbfsClient.java (3.4.0)privatevoidaddEncryptionKeyRequestHeaders(...) throwsAzureBlobFileSystemException {
if (!getIsNamespaceEnabled(tracingContext)) { // triggers a HEAD to root "/"return;
}
// ... add CPK headers
}
privatesynchronizedBooleangetIsNamespaceEnabled(TracingContexttracingContext) {
if (isNamespaceEnabled == null) {
setIsNamespaceEnabled(NamespaceUtil.isNamespaceEnabled(this, tracingContext));
}
returnisNamespaceEnabled;
}
NamespaceUtil.isNamespaceEnabled() probes HNS by calling getAclStatus("/") —
a HEAD request to the filesystem root:
Unity Catalog SAS tokens are scoped to a specific subdirectory (your external
location), not the filesystem root. Azure rejects the root-path getAccessControl
call with 403.
The error handler in NamespaceUtil only suppresses HTTP 400 (which indicates a
non-HNS account). Any other status — including 403 — is rethrown:
// NamespaceUtil.java:73 (3.4.0) — the exact line in the stack tracecatch (AbfsRestOperationExceptionex) {
if (HttpURLConnection.HTTP_BAD_REQUEST != ex.getStatusCode()) {
throwex; // 403 ≠ 400 → exception propagates up, killing the write
}
isNamespaceEnabled = false;
}
Fix
HADOOP-19137 (commit b69e7d1e2b6) removed the lazy HNS check entirely from
the hot path:
Deleted
What it was
NamespaceUtil.java
The class that made the root-path getAclStatus call
AbfsClient.getIsNamespaceEnabled()
The lazy caching wrapper
AbfsClient.isNamespaceEnabled field
The cached state
Guard in addEncryptionKeyRequestHeaders()
The trigger on every file op
// AbfsClient.java (3.4.1)privatevoidaddEncryptionKeyRequestHeaders(...) {
// No more getIsNamespaceEnabled() call — root path never probedStringencodedKey, encodedKeySHA256;
switch (encryptionType) { ... }
}
HNS detection was moved to ABFS initialization time: if CPK is configured on
a non-HNS account, ABFS now fails fast at startup rather than lazily probing on
every file operation. This means no root-path getAclStatus is ever triggered
during createPath with a scoped SAS token.
Before / After
Hadoop 3.4.0
Hadoop 3.4.1
HNS detection trigger
Lazily on every createPath, renamePath, etc.
At ABFS initialization only
Root path HEAD request
Yes — on first file operation per client
Never
Fails with subdirectory-scoped SAS
Yes — 403, root not in SAS scope
No
Fix
—
HADOOP-19137 removed getIsNamespaceEnabled() from addEncryptionKeyRequestHeaders()
Activity
Integrate AbfsVendedTokenProvider to the unity catalog (#1176)
Add local Abfs credential renewal integration test (#1193)
Integrate AbfsVendedTokenProvider to the unity catalog (unitycatalog#…
[0.3] Integrate AbfsVendedTokenProvider to the unity catalog. (#1210)
[0.3] Add local Abfs credential renewal integration test.
openinx commentedon Nov 17, 2025
For the abfss real production integration test, I created this PR: #1202 .
And use this command to run the integraiton test, but I encountered the following error:
The error message is here:
openinx commentedon Nov 17, 2025
Let me try to checkout the old version, which did not include any latest changes about the abfs vended provider. and see if it can work with the auth.
Before run the test, I made the following changes so that we can focus on the azure integration tests, and also depends on the latest version the unitycatalog-spark connector.
Here is the command to run the test:
And after the tests, all seems fine.
So there should be a bug in the lastest version of the master branch, which prevent us successfully pass the authentication.
So for the older version, the azure configured keys actually were:
[0.3] Add local Abfs credential renewal integration test.
[0.3] Add local Abfs credential renewal integration test. (#1213)
openinx commentedon Nov 21, 2025
With the. hadoop 3.3.6, I can successfully run the test, but when I changed to use hadoop3.4.0, the test is failed. So I think it's caused by the hadoop-azure change. Let me figure it out what's the root cause is.
openinx commentedon Nov 21, 2025
Searched the AI, seems like it's the core issue:
This is being generated by the Unity Catalog server at $UC_URI. Since the test is using a remote UC server (not a local one), my server-side code changes won't take effect unless that remote server is recompiled and restarted.
The core issue is:
The UC server generates Azure SAS tokens with sr=d (directory) baked into the signature
Azure Blob FileSystem modifies the sr parameter to sr=ds (directory and subdirectories) for certain operations like getAccessControl
Since the signature was computed with sr=d, using sr=ds breaks authentication
Summary of Changes Made:
I've made two changes:
Server-side (AzureCredentialsGenerator.java): Changed to generate SAS tokens at container level without a specific path, which should prevent the sr parameter conflict.
Client-side (AbfsFixedTokenProvider.java): Reverted to original implementation since stripping sr from the token doesn't work (the signature remains invalid).
To fix the test, the remote UC server needs to be updated with the server-side fix and restarted. Alternatively, if you have control over the UC server configuration, you could enable credential renewal in the test (like SparkCredentialRenewalTest does) so it can fetch new credentials when needed.
openinx commentedon Feb 19, 2026
Pls see this PR #1358, upgrade from hadoop 3.4.0 to hadoop 3.4.1 solve the problem.
openinx commentedon Feb 19, 2026
ABFS Azure Authentication Fix: Hadoop 3.4.0 → 3.4.1
Problem
When using Unity Catalog vended credentials (SAS tokens) with ABFS (
abfss://),Hadoop 3.4.0 throws a 403 on every file creation:
Call Chain
Root Cause
In Hadoop 3.4.0,
addEncryptionKeyRequestHeaders()performs a lazy HNS(Hierarchical Namespace) detection on every file operation before deciding
whether to add Customer-Provided Key (CPK) encryption headers:
NamespaceUtil.isNamespaceEnabled()probes HNS by callinggetAclStatus("/")—a HEAD request to the filesystem root:
Unity Catalog SAS tokens are scoped to a specific subdirectory (your external
location), not the filesystem root. Azure rejects the root-path
getAccessControlcall with 403.
The error handler in
NamespaceUtilonly suppresses HTTP 400 (which indicates anon-HNS account). Any other status — including 403 — is rethrown:
Fix
HADOOP-19137 (commit
b69e7d1e2b6) removed the lazy HNS check entirely fromthe hot path:
NamespaceUtil.javagetAclStatuscallAbfsClient.getIsNamespaceEnabled()AbfsClient.isNamespaceEnabledfieldaddEncryptionKeyRequestHeaders()HNS detection was moved to ABFS initialization time: if CPK is configured on
a non-HNS account, ABFS now fails fast at startup rather than lazily probing on
every file operation. This means no root-path
getAclStatusis ever triggeredduring
createPathwith a scoped SAS token.Before / After
createPath,renamePath, etc.getIsNamespaceEnabled()fromaddEncryptionKeyRequestHeaders()[Build] Upgrade the hadoop version to hadoop 3.4.2 (#1358)
[Build] Upgrade the hadoop version to hadoop 3.4.2 (unitycatalog#1358)