Xuanwo opened a new pull request, #8841: URL: https://github.com/apache/opendal/pull/8841
# Which issue does this PR close? Closes # # Rationale for this change Closing an append-mode writer without writing data skipped the service entirely. `WriteGenerator::write_all` does not call `oio::Write::write` for an empty buffer, so `AppendWriter::write` never ran and the service was never asked where the object ends. `AppendWriter::close` then built its result from the cached offset, which defaults to `0`. Two defects followed: - On a missing object, `write_with(path, "").append(true)` returned `Ok` while the object was never created, although `Writer` promises to create a missing object like `write` does. - On an existing object, `close` reported `content_length` `0` with no metadata, discarding the real length, the service `etag` and last modified time, and never letting the service enforce `if_match` or `if_not_exists`. # What changes are included in this PR? - `AppendWriter` records whether an append has succeeded. `close` resolves the offset and appends an empty buffer when it has not, so the object is created and the returned metadata comes from the service. - The offset lookup and append now live in `AppendWriter` helpers shared by `write` and `close`. The offset only advances after a successful append, so a retried `close` resends the empty append at the same position instead of skipping it. - `AppendWrite::append` documents that it receives a zero-byte append when a writer closes without data. - `AzblobWriter::append` returns the blob properties for a zero-byte append because Azure rejects `Append Block` with an empty body (`InvalidHeaderValue`, reproduced with Azurite, the backend used by the `azblob` behavior tests). - Unit tests in `core/core/src/raw/oio/write/append_write.rs` cover a missing object, an existing object, a retry after a temporary append failure, a non-empty write followed by `close`, and an empty `write` followed by `close`. # Are there any user-facing changes? An empty append-mode write now creates the object and returns its real length and metadata. Services whose `offset` fails for a missing object surface that error instead of a fabricated zero-length result; `azfile` is the case in this tree. # Breaking changes # AI Usage Statement - Harness: pi coding agent (T3 Code) - Model: DeepSeek - Effort: max - Role: The AI wrote the change, the unit tests, and the commit message, and ran the verification listed below. The AI also reproduced both defects and the fixed behavior against Azurite through the `azblob` service before and after the change. Verified by the AI: - `cargo fmt --all -- --check`, `cargo clippy -p opendal-core -p opendal-service-azblob --all-targets -- -D warnings` - `cargo test -p opendal-core -p opendal-service-azblob --lib --locked` (429 and 19 tests) - `cargo test --lib --locked` for `opendal-service-s3`, `-oss`, `-cos`, `-obs`, `-azdls`, `-azfile`, `-webhdfs` - `cargo doc -p opendal-core --lib --no-deps --all-features` without warnings Assumptions and unknowns affecting review: - Against Azurite, `op.write_with(path, "").append(true)` returned `content_length` `0` and `etag: None` without creating the object before the change; afterwards it returns the created object metadata. For an existing 10-byte object the same call returned `content_length` `0` and `etag: None` before, and `content_length` `10` with the unchanged `etag` and `last_modified` after. - A zero-byte append was not exercised against the real `s3`, `oss`, `cos`, `obs`, `azdls`, `webhdfs`, or `azfile` services. Only Azure Blob Storage rejects it in this tree today; the other implementations send the request to the service and their behavior is unverified here. -- 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]
