Xuanwo opened a new pull request, #8834:
URL: https://github.com/apache/opendal/pull/8834
# Which issue does this PR close?
N/A.
# Rationale for this change
`S3Core::s3_append_object_request` only called `insert_metadata_headers`
when `position == 0`, and `If-Match` / `If-None-Match: *` were emitted inside
`insert_metadata_headers`. As a result, appending to an existing object
(`position > 0`) silently dropped caller preconditions. In addition,
`S3Writer::append` only attached `with_caller_condition(...)` to `ErrorContext`
when `offset == 0`, so a `412 Precondition Failed` response at `offset > 0`
would be classified as `ErrorKind::Unexpected` instead of
`ErrorKind::ConditionNotMatch`, and a `404 NoSuchKey` response to `If-Match`
was not normalized to `ConditionNotMatch` like `write_once` and `complete_part`.
This violated `core/core/src/docs/specs/conditional-operations.md` ("OpenDAL
never silently ignores a condition").
# What changes are included in this PR?
- Remove `If-Match` and `If-None-Match` emission from
`S3Core::insert_metadata_headers` and emit them explicitly in
`s3_put_object_request` and `s3_append_object_request`.
- Track whether an `S3Writer` has completed its first append (`appended:
AtomicBool`) so the writer's first append emits `If-Match` / `If-None-Match: *`
and sets `with_caller_condition(self.op.is_conditional())` regardless of
whether `offset == 0` or `offset > 0`, while subsequent chunks from the same
multi-chunk writer omit the initial condition (avoiding self-induced 412
failures after chunk 1 creates the object or updates its ETag).
- Map `404 NotFound` on conditional `If-Match` appends to
`ErrorKind::ConditionNotMatch`, matching `write_once` and `complete_part`.
- Add deterministic unit tests in `core/services/s3/src/backend.rs` covering
existing-object conditional appends (`if_match`, `if_not_exists`, 412, and
404), new-object appends without duplicated headers, multi-chunk append
behavior, and non-append conditional `PutObject`.
# Are there any user-facing changes?
Conditional append writes on S3 (`append(true)` with `if_match` or
`if_not_exists`) now enforce the caller's precondition when appending to
existing objects instead of silently ignoring it, and surface precondition
failures as `ErrorKind::ConditionNotMatch`.
# Breaking changes
# AI Usage Statement
- Harness: Pi
- Model: Gemini 4 Neon
- Effort: High
- Role: Investigated the conditional append bug, implemented the fix in
`core/services/s3`, added unit tests with `S3ExpressMockTransport`, and
verified formatting, clippy, and unit tests. Note: validation used
deterministic mock-transport unit tests; live AWS S3 Express One Zone behavior
tests were not run in this environment.
--
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]