fix: preserve ABFS container in object store registry keys - #23935
fix: preserve ABFS container in object store registry keys#23935847850277 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a key-collision bug in DefaultObjectStoreRegistry for Azure ABFS/ABFSS URLs by ensuring the registry key derivation preserves the container namespace encoded in URL userinfo (e.g. abfss://<container>@<account>...). This prevents one registered ABFS container store from overwriting another when they share the same Azure account host.
Changes:
- Make
get_url_keyscheme-aware: preserve userinfo forabfs/abfss, continue stripping it for other schemes. - Update documentation comments for
get_url_keyto reflect the new behavior. - Add regression tests covering both
abfsandabfss, including separate registration of multiple containers under one account.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let key_authority = match url.scheme() { | ||
| // ABFS encodes the container namespace in URL userinfo. | ||
| "abfs" | "abfss" => &url[url::Position::BeforeUsername..url::Position::AfterPort], | ||
| _ => &url[url::Position::BeforeHost..url::Position::AfterPort], | ||
| }; | ||
|
|
||
| format!("{}://{key_authority}", url.scheme()) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23935 +/- ##
=======================================
Coverage 80.68% 80.68%
=======================================
Files 1095 1095
Lines 372534 372568 +34
Branches 372534 372568 +34
=======================================
+ Hits 300579 300607 +28
- Misses 54015 54020 +5
- Partials 17940 17941 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| let key_authority = match url.scheme() { | ||
| // ABFS encodes the container namespace in URL userinfo. | ||
| "abfs" | "abfss" => &url[url::Position::BeforeUsername..url::Position::AfterPort], | ||
| _ => &url[url::Position::BeforeHost..url::Position::AfterPort], | ||
| }; | ||
|
|
||
| format!("{}://{key_authority}", url.scheme()) |
| let key_authority = match url.scheme() { | ||
| // ABFS encodes the container namespace in URL userinfo. | ||
| "abfs" | "abfss" if !url.username().is_empty() => format!( | ||
| "{}@{}", | ||
| &url[url::Position::BeforeUsername..url::Position::AfterUsername], | ||
| &url[url::Position::BeforeHost..url::Position::AfterPort], | ||
| ), | ||
| _ => url[url::Position::BeforeHost..url::Position::AfterPort].to_string(), | ||
| }; | ||
|
|
||
| format!("{}://{key_authority}", url.scheme()) |
There was a problem hiding this comment.
| let key_authority = match url.scheme() { | |
| // ABFS encodes the container namespace in URL userinfo. | |
| "abfs" | "abfss" if !url.username().is_empty() => format!( | |
| "{}@{}", | |
| &url[url::Position::BeforeUsername..url::Position::AfterUsername], | |
| &url[url::Position::BeforeHost..url::Position::AfterPort], | |
| ), | |
| _ => url[url::Position::BeforeHost..url::Position::AfterPort].to_string(), | |
| }; | |
| format!("{}://{key_authority}", url.scheme()) | |
| let authority_start = match url.scheme() { | |
| "abfs" | "abfss" if !url.username().is_empty() => url::Position::BeforeUsername, | |
| _ => url::Position::BeforeHost, | |
| }; | |
| format!( | |
| "{}://{}", | |
| url.scheme(), | |
| &url[authority_start..url::Position::AfterPort], | |
| ) |
| let key_authority = match url.scheme() { | ||
| // ABFS encodes the container namespace in URL userinfo. | ||
| "abfs" | "abfss" => &url[url::Position::BeforeUsername..url::Position::AfterPort], | ||
| _ => &url[url::Position::BeforeHost..url::Position::AfterPort], | ||
| }; | ||
|
|
||
| format!("{}://{key_authority}", url.scheme()) |
|
also cc @andygrove — related to apache/datafusion-comet#5053 |
Which issue does this PR close?
Rationale for this change
ABFS and ABFSS URLs encode the container namespace in URL userinfo:
The object store registry currently removes userinfo when deriving its key. As a result, different containers under the same Azure account produce the same key, allowing one registered store to overwrite another
What changes are included in this PR?
Are these changes tested?
yes
Are there any user-facing changes?
@peterxcli
I have submitted a pr. could you please help review it when you have time? Thanks!