Skip to content

Commit 55fb54d

Browse files
committed
refactor: render the ABFS native fallback reason's location with displayAuthority
nativeFallbackReason stripped the URL password with its own copy of the logic in NativeConfig.authorityWithoutPassword. Use the shared helpers so the resolver renders a location one way in every message: lower-case scheme, no password, path or query.
1 parent 1aa8c51 commit 55fb54d

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎spark/src/main/scala/org/apache/comet/objectstore/AbfsAuthResolver.scala‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,8 @@ private[comet] object AbfsAuthResolver extends Logging {
484484
def nativeFallbackReason(uri: URI, outcome: Outcome): Option[String] = {
485485
// The container and host only: a password in the user info stays out of the reason.
486486
val authority = Option(uri.getRawAuthority).getOrElse("")
487-
val at = authority.lastIndexOf('@')
488-
val safeAuthority =
489-
if (at < 0) authority
490-
else authority.substring(0, at).takeWhile(_ != ':') + authority.substring(at)
491-
val location = s"${uri.getScheme}://$safeAuthority"
487+
val safeAuthority = NativeConfig.authorityWithoutPassword(uri)
488+
val location = display(uri)
492489
outcome match {
493490
case Declined(authType, providerClass, assertionProviderClass) =>
494491
val classes = providerClass.map(c => s" with provider $c").getOrElse("") +

‎spark/src/test/scala/org/apache/comet/objectstore/NativeConfigSuite.scala‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,17 @@ class NativeConfigSuite extends AnyFunSuite with Matchers {
878878
"auth type UserboundSASWithOAuth")
879879
}
880880

881+
test("nativeFallbackReason - renders the location as the resolver's other messages do") {
882+
val uri =
883+
new URI("ABFSS://data:[email protected]/dir/f.parquet?sig=SAS-MARKER")
884+
val reason =
885+
AbfsAuthResolver.nativeFallbackReason(uri, AbfsAuthResolver.Declined("Custom", None)).get
886+
reason should include(NativeConfig.displayAuthority(uri))
887+
reason should include("abfss://[email protected]")
888+
reason should not include "pw-secret"
889+
reason should not include "SAS-MARKER"
890+
}
891+
881892
test("nativeStoreError - passes native's answer through") {
882893
val options = Map("a" -> "1", "b" -> "2")
883894
var seen = Map.empty[String, String]

0 commit comments

Comments
 (0)