This is an automated email from the ASF dual-hosted git repository.
Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new a8fcf2235c docs(integrations/object_store): document OpendalStore path
resolution convention (#8728)
a8fcf2235c is described below
commit a8fcf2235c47cb1ded49881af2b284a45800dd53
Author: Xuanwo <[email protected]>
AuthorDate: Mon Nov 23 05:26:02 2026 +0800
docs(integrations/object_store): document OpendalStore path resolution
convention (#8728)
Explain how OpendalStore maps object_store::path::Path to keys resolved
against the operator's configured root, and how that interacts with
URL-based registries such as DataFusion's ObjectStoreRegistry, which
keys stores by scheme plus authority and hands the store the full URL
path. Repeating the same prefix in both the operator root and queried
URLs produces a doubled prefix and failed lookups, as reported in
apache/opendal#7786.
Add a runnable doctest on OpendalStore::new that demonstrates
root-relative path resolution and the double-prefix failure mode using
the memory service, and summarize the convention in the crate docs and
README.
Refs #7786
---
integrations/object_store/README.md | 23 ++++++++++
integrations/object_store/src/lib.rs | 10 +++++
integrations/object_store/src/store.rs | 78 ++++++++++++++++++++++++++++++++++
3 files changed, 111 insertions(+)
diff --git a/integrations/object_store/README.md
b/integrations/object_store/README.md
index 377a3ac4bf..99bc1edd53 100644
--- a/integrations/object_store/README.md
+++ b/integrations/object_store/README.md
@@ -86,6 +86,29 @@ async fn main() {
}
```
+### Path resolution
+
+`OpendalStore` forwards every `object_store::path::Path` to the `Operator`,
+which resolves it against the operator's configured `root`: a store path
+`data/test.txt` reaches the service as `<root>/data/test.txt`. The store never
+strips a leading prefix, because any prefix can be a legitimate object key
+inside the root.
+
+When the store is registered with a URL-based registry such as DataFusion's
+`ObjectStoreRegistry`, the registry key contains only the registered URL's
+scheme and authority, so the store receives the full path of each queried URL.
+Keep the prefix in exactly one place to avoid the double-prefixing reported in
+[apache/opendal#7786](https://github.com/apache/opendal/issues/7786):
+
+- Leave the operator `root` unset so queried URLs carry the full path to each
+ object, as `s3://bucket/key` does.
+- Set `root` to the shared prefix and register the store under a URL whose
+ queried paths are relative to it. For services such as `hf://` whose
+ authority does not encode the bucket or repository, configure the repository
+ on the builder and register a dedicated authority (for example
+ `hf://myrepo`) so that `hf://myrepo/file` hands the store a
+ repository-relative `file`.
+
### Object attributes and renames
`get` and `get_opts` expose the content attributes and user metadata returned
diff --git a/integrations/object_store/src/lib.rs
b/integrations/object_store/src/lib.rs
index 7d20115300..1170ab32bc 100644
--- a/integrations/object_store/src/lib.rs
+++ b/integrations/object_store/src/lib.rs
@@ -61,6 +61,16 @@
//! }
//! ```
//!
+//! # Path resolution
+//!
+//! `OpendalStore` forwards each [`object_store::path::Path`] to the
`Operator`,
+//! which resolves it against its configured `root`; prefixes are never
+//! stripped. When the store is registered with a URL-based registry such as
+//! DataFusion's `ObjectStoreRegistry`, keep the shared prefix in exactly one
+//! place — in the queried URL paths or in the operator `root` — to avoid
+//! double-prefixing. See [`OpendalStore::new`] for the full convention and a
+//! runnable example.
+//!
//! Use the re-exported future helper when an integration needs the same
OpenDAL
//! future wrapper used by this crate:
//!
diff --git a/integrations/object_store/src/store.rs
b/integrations/object_store/src/store.rs
index 3b7f2cec55..468d93467b 100644
--- a/integrations/object_store/src/store.rs
+++ b/integrations/object_store/src/store.rs
@@ -141,6 +141,10 @@ fn format_read_range(range: Option<&GetRange>, size: u64)
-> Range<u64> {
///
/// This allows users to use opendal as an object store without extra cost.
///
+/// Paths are resolved against the operator's configured root; see
+/// [`OpendalStore::new`] for the path resolution convention and a runnable
+/// example.
+///
/// Visit [`opendal::services`] for more information about supported services.
///
/// ```no_run
@@ -195,6 +199,80 @@ pub struct OpendalStore {
impl OpendalStore {
/// Create OpendalStore by given Operator.
+ ///
+ /// # Path resolution
+ ///
+ /// `OpendalStore` forwards every incoming [`object_store::path::Path`] to
+ /// the operator, which resolves it against its configured `root`: a store
+ /// path `data/test.txt` reaches the service as `<root>/data/test.txt`.
+ /// `OpendalStore` never strips a leading prefix, because any prefix can be
+ /// a legitimate object key inside the root.
+ ///
+ /// This matters when the store is registered with a URL-based registry
+ /// such as DataFusion's `ObjectStoreRegistry`. The registry key contains
+ /// only the registered URL's scheme and authority, so the store receives
+ /// the full path of each queried URL. If the same prefix is configured in
+ /// both the operator `root` and the queried URLs, lookups fail with a
+ /// doubled prefix, as reported in [apache/opendal#7786]. Choose the
+ /// single place that owns the prefix:
+ ///
+ /// - Leave the operator `root` unset so queried URLs carry the full path
+ /// to each object, as `s3://bucket/key` does.
+ /// - Set `root` to the shared prefix and register the store under a URL
+ /// whose queried paths are relative to it. For services such as `hf://`
+ /// whose authority does not encode the bucket or repository, configure
+ /// the repository on the builder and register a dedicated authority
+ /// (for example `hf://myrepo`) so that `hf://myrepo/file` hands the
+ /// store a repository-relative `file`.
+ ///
+ /// The following example uses the memory service but applies to any
+ /// service. The memory scheme has no meaningful authority, so the
+ /// `memory://my-store` registration below only fixes the URL prefix used
+ /// for lookups; the operator `root` owns the `base/dir` prefix.
+ ///
+ /// [apache/opendal#7786]: https://github.com/apache/opendal/issues/7786
+ ///
+ /// ```
+ /// use std::sync::Arc;
+ ///
+ /// use bytes::Bytes;
+ /// use object_store::path::Path;
+ /// use object_store::{ObjectStore, ObjectStoreExt};
+ /// use object_store_opendal::OpendalStore;
+ /// use opendal::services::Memory;
+ /// use opendal::Operator;
+ ///
+ /// #[tokio::main]
+ /// async fn main() {
+ /// // The operator owns the `base/dir` prefix through its root.
+ /// let op =
Operator::new(Memory::default().root("/base/dir")).unwrap();
+ /// let store = OpendalStore::new(op.clone());
+ ///
+ /// // Paths passed to the store are store-relative keys: the service
+ /// // sees them resolved against `/base/dir`.
+ /// let path = Path::from("data/test.txt");
+ /// store
+ /// .put(&path, Bytes::from_static(b"hello").into())
+ /// .await
+ /// .unwrap();
+ /// assert_eq!(op.read("data/test.txt").await.unwrap().len(), 5);
+ ///
+ /// // A URL-based registry hands the store the path that follows the
+ /// // authority. Registering `memory://my-store` makes
+ /// // `memory://my-store/data/test.txt` reach this store as the same
+ /// // store-relative `data/test.txt`.
+ /// let content =
store.get(&path).await.unwrap().bytes().await.unwrap();
+ /// assert_eq!(content, Bytes::from_static(b"hello"));
+ ///
+ /// // Repeating the root in the queried URL path looks up
+ /// // `/base/dir/base/dir/data/test.txt`: prefixes are never stripped.
+ /// let doubled = Path::from("base/dir/data/test.txt");
+ /// assert!(matches!(
+ /// store.head(&doubled).await,
+ /// Err(object_store::Error::NotFound { .. })
+ /// ));
+ /// }
+ /// ```
pub fn new(op: Operator) -> Self {
Self {
info: op.info().into(),