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

   # Which issue does this PR close?
   
   N/A
   
   # Rationale for this change
   
   Fixes seven verified correctness and protocol-compliance bugs in 
`services/azblob`:
   
   1. **Append preconditions and user metadata (`AzblobWriter`)**: 
`AzblobBackend` advertises `write_can_append`, `write_with_if_match`, 
`write_with_if_none_match`, and `write_with_user_metadata`, but `AppendWrite` 
dropped `x-ms-meta-*` when initializing an append blob, initialized a new blob 
on `404` even when `if_match` was set, and never sent `If-Match` / 
`If-None-Match` on the first append (or empty append).
   2. **Batch delete `Content-ID` correlation 
(`AzblobDeleter::delete_batch`)**: Azure Blob Batch sub-responses are not 
guaranteed to arrive in request order and must be correlated by each part's 
`Content-ID` header. Zipping responses positionally misattributed partial 
failures and successes.
   3. **Single-shot copy SSE-C headers (`azblob_copy_blob`)**: 
`azblob_copy_blob` was the only blob mutation/read request in `AzblobCore` that 
omitted customer-provided encryption (`insert_sse_headers`) headers.
   4. **Lister pagination and empty properties (`AzblobLister`)**: Omitting 
`<NextMarker>` left `ctx.done` as `false` with an empty token, risking infinite 
pagination; empty `<Content-MD5 />`, `<Content-Type />`, or `<Etag />` values 
(such as `<Content-MD5>` on `AppendBlob` and `PutBlockList` blobs) were stored 
as empty strings or `""` instead of `None`.
   5. **Container-not-found masking on delete (`AzblobDeleter`)**: Both 
`delete_once` and `delete_batch` treated every HTTP `404` as idempotent success 
(or `ConditionNotMatch` under `if_match`), swallowing `404 ContainerNotFound` 
instead of surfacing `ErrorKind::ConfigInvalid`.
   6. **Duplicate `If-None-Match` header**: Setting both `if_not_exists(true)` 
and `if_none_match(...)` emitted two `If-None-Match` headers across `PutBlob`, 
append initialization, `PutBlockList`, copy `PutBlockList`, and `CopyBlob`.
   7. **Reader metadata parity (`AzblobReader::open`)**: `AzblobReader::open` 
dropped `x-ms-version-id` and `x-ms-meta-*` headers that `AzblobBackend::stat` 
already parsed.
   
   # What changes are included in this PR?
   
   - **`core/core/src/raw/http_util/multipart.rs`**:
     - Add `MixedPart::part_headers(&self) -> &HeaderMap` so batch response 
consumers can inspect parsed multipart part headers such as `Content-ID`.
   - **`core/services/azblob/src/core.rs` & 
`core/services/azblob/src/writer.rs`**:
     - Attach `x-ms-meta-*` and `If-None-Match` on 
`azblob_init_appendable_blob_request`.
     - Track whether append preconditions have already been checked 
(`conditions_checked: AtomicBool`) so `AzblobWriter` rejects missing blobs 
under `if_match`, applies `If-Match` / `If-None-Match` on the first 
`AppendBlock` (and on empty appends via `GetBlobProperties`), and does not 
re-send initial preconditions on subsequent chunks or after initializing a new 
blob.
     - Extract `azblob_copy_blob_request` and include `insert_sse_headers`.
     - Give `if_not_exists` precedence over `if_none_match` (preserving their 
logical conjunction with `If-None-Match: *`) to avoid duplicate `If-None-Match` 
headers across write and copy request builders.
     - Map `ContainerNotFound` to `ErrorKind::ConfigInvalid` in 
`parse_azblob_error_code` and add `parse_error_with_code` for 404 code 
inspection.
     - Extract shared `parse_blob_metadata` for `x-ms-version-id` and 
`x-ms-meta-*` headers.
   - **`core/services/azblob/src/deleter.rs`**:
     - Correlate `delete_batch` sub-responses by `Content-ID` (validating 
bounds, uniqueness, and completeness, with positional fallback only when all 
parts omit `Content-ID`).
     - Parse `404` responses in both `delete_once` and `delete_batch`, treating 
only `BlobNotFound` and `ParentNotFound` as missing blobs and surfacing 
`ContainerNotFound` (`ConfigInvalid`) and other `404` errors.
   - **`core/services/azblob/src/lister.rs`**:
     - Mark `ctx.done = 
output.next_marker.as_deref().is_none_or(str::is_empty)` and omit empty `etag`, 
`content_md5`, `content_type`, and `last_modified` fields without 
double-quoting pre-quoted ETags.
   - **`core/services/azblob/src/reader.rs` & 
`core/services/azblob/src/backend.rs`**:
     - Share `parse_blob_metadata` between `AzblobBackend::stat` and 
`AzblobReader::open`.
   - **Tests**:
     - Add deterministic unit tests in `core.rs`, `writer.rs`, `deleter.rs`, 
`lister.rs`, `reader.rs`, and `multipart.rs` covering all seven fixes, and 
verify against a local Azurite 3.38.0 instance (including live error codes for 
`ContainerNotFound` vs `BlobNotFound`, conditional append with user metadata, 
listing append blobs, and reader metadata).
   
   # Are there any user-facing changes?
   
   - Deleting against a non-existent Azure Blob container now fails with 
`ErrorKind::ConfigInvalid` instead of succeeding silently (or returning 
`ErrorKind::ConditionNotMatch`).
   - Append writes now enforce `if_match` / `if_none_match` and preserve 
`user_metadata` on newly created append blobs.
   - `AzblobLister` no longer populates empty strings for absent `content_md5` 
/ `content_type` / `etag` properties, and `AzblobReader::open` now includes 
`version` and `user_metadata`.
   - `opendal_core::raw::MixedPart` adds a new `pub fn part_headers(&self) -> 
&HeaderMap` accessor.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Audited `core/services/azblob` against `core/core` and Azure Blob 
Storage behavior, implemented the fixes and unit tests, and verified them with 
unit tests and a local Azurite 3.38.0 instance. Customer-provided encryption 
(CPK) headers on `CopyBlob` were verified via unit tests; HTTPS CPK execution 
against live Azure Storage was not run locally.
   


-- 
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