Xuanwo opened a new pull request, #8840:
URL: https://github.com/apache/opendal/pull/8840

   # Which issue does this PR close?
   
   N/A.
   
   # Rationale for this change
   
   `OpendalStore` had three correctness bugs in 
`integrations/object_store/src/store.rs`:
   
   1. Directories on backends such as `fs` (and root paths on `memory`) were 
exposed as 0-byte objects on `head()`, `get()`, and `get_opts(..., GetOptions { 
head: true, .. })` instead of returning `object_store::Error::NotFound`, 
diverging from `OpendalStore::list` and `object_store`'s `LocalFileSystem` / 
`InMemory`.
   2. `PutMode::Update(UpdateVersion)` ignored `UpdateVersion.version` whenever 
`e_tag` was present, weakening conditional writes on versioned backends instead 
of enforcing the version precondition or failing closed with `NotSupported`.
   3. `get_opts_with_stat` forwarded unsupported preconditions to `stat()` and 
`reader_options()` (and skipped local precondition evaluation for `head: true` 
or unsupported ETag conditions), causing conditional `get_opts` / `head` calls 
on backends without native stat/read precondition capabilities (such as `fs` 
and `memory`) to fail with `NotSupported` instead of evaluating 
`GetOptions::check_preconditions` locally.
   
   # What changes are included in this PR?
   
   - Return `object_store::Error::NotFound` when `get_opts_without_stat` or 
`get_opts_with_stat` encounters directory metadata (`metadata.is_dir()`) before 
evaluating preconditions or short-circuiting empty/head responses, and map 
`ErrorKind::IsADirectory` to `NotFound` in `format_get_error`.
   - Forward `UpdateVersion.version` via `WriteOptions::if_version_match` 
alongside `UpdateVersion.e_tag` via `WriteOptions::if_match` in `put_opts` 
(rejecting empty updates with `NotSupported`), so OpenDAL's capability check 
fails closed with `NotSupported` whenever a requested ETag or version 
precondition is unsupported instead of silently dropping `version`.
   - In `get_opts_with_stat`, forward only the preconditions supported natively 
by `stat_with_*` and `read_with_*` capabilities (while keeping `version` 
selectors intact and preserving the native fast paths on backends that support 
them), and evaluate `options.check_preconditions(&meta)` locally whenever any 
precondition was not enforced by `stat` (including `head: true`).
   - Add offline unit tests in `integrations/object_store/src/store.rs` 
covering directory `NotFound`, `PutMode::Update` version handling, and 
conditional `get_opts` / `head` fallback on `fs` and `memory`.
   
   # Are there any user-facing changes?
   
   Yes:
   - `head`, `get`, and `get_opts` on directory paths now return 
`object_store::Error::NotFound` instead of a 0-byte object.
   - `put_opts` with `PutMode::Update` now enforces `UpdateVersion.version` via 
`if_version_match` or returns `NotSupported` when the backend does not support 
it, rather than silently ignoring `version`.
   - Conditional `get_opts` / `head` requests on backends lacking native 
stat/read precondition support now evaluate preconditions locally (returning 
`Ok`, `NotModified`, or `Precondition`) instead of failing with `NotSupported`.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Investigated the three correctness bugs in 
`integrations/object_store/src/store.rs`, implemented the fixes, added unit 
tests comparing against `object_store`'s `LocalFileSystem` and `InMemory` plus 
a capability probe layer for `PutMode::Update`, and verified with local 
formatting, clippy, and tests.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to