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

   # Which issue does this PR close?
   
   Refs #6274.
   
   # Rationale for this change
   
   Backblaze B2 already advertises `write_with_user_metadata` and 
`presign_write`, and ordinary single-object uploads (`B2Core::upload_file`) 
forward `WriteOptions::user_metadata` as `X-Bz-Info-*` headers encoded with 
`percent_encode_path`. Previously, `B2Backend::presign` ignored 
`WriteOptions::user_metadata` when building a single-object presigned upload 
POST, so callers received a valid upload request that silently dropped user 
metadata.
   
   # What changes are included in this PR?
   
   - `core/services/b2/src/backend.rs`: Forward `WriteOptions::user_metadata` 
in `B2Backend::presign` (`PresignOperation::Write`) as `X-Bz-Info-*` headers 
encoded with `percent_encode_path`, reusing the same encoding as ordinary 
single-object uploads.
   - `core/tests/behavior/async_presign.rs`: Rename 
`test_presign_write_b2_content_type` to `test_presign_write_b2_headers` and 
verify default (`b2/x-auto`) and explicit `Content-Type` alongside the 
percent-encoded `X-Bz-Info-*` metadata header on the returned presigned request.
   
   ## Verification
   
   - **Committed header-only regression (`test_presign_write_b2_headers`):** 
Checks only the header map returned by `presign_write` and 
`presign_write_options` (default `Content-Type: b2/x-auto`, explicit 
`Content-Type: application/json`, and percent-encoded 
`x-bz-info-application-validation`) without uploading objects. Passed against a 
native Backblaze B2 fixture, alongside focused `opendal-service-b2` unit tests, 
clippy, and formatting checks.
   - **Live end-to-end persisted proof:** Separately tested against a native 
Backblaze B2 fixture in a fresh isolated prefix by uploading an 18-byte payload 
with `WriteOptions::user_metadata` (`application-validation=b2 trial + café %`) 
through both ordinary `write_options` and executing the unchanged POST returned 
by `presign_write_options`:
     - **Before (`dfe9ddf1db`):** Ordinary `write_options` persisted the exact 
metadata value (confirmed by independent `Operator::stat`, native 
`b2_get_file_info`, and native download by file ID). The presigned POST lacked 
`X-Bz-Info-application-validation` and returned HTTP 200 with exact bytes and 
matching file ID, while both `Operator::stat` and `b2_get_file_info` confirmed 
the metadata was absent.
     - **After (`41d88cec51`):** The returned presigned POST included 
`Content-Type: b2/x-auto` and the encoded `X-Bz-Info-application-validation` 
header. Executing the POST returned HTTP 200; independent `Operator::stat` and 
native `b2_get_file_info` both confirmed the exact persisted metadata value, 
and native download by file ID matched the upload receipt's file ID and 
returned all 18 expected bytes. (An initial candidate attempt received a 
transient HTTP 503 on the POST and cleaned up its control object; the 
subsequent attempt in a fresh prefix passed and verified zero remaining 
versions, hide markers, or unfinished uploads.)
   
   # Are there any user-facing changes?
   
   `Operator::presign_write_options` on native Backblaze B2 now forwards 
`WriteOptions::user_metadata` as percent-encoded `X-Bz-Info-*` headers on 
single-object presigned upload POST requests, matching ordinary `write_options` 
uploads.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - **Harness:** Pi (via T3 Code)
     **Model:** `magpie/codex/gpt-6.2-sol`
     **Effort:** `max`
     **Role:** Implemented `WriteOptions::user_metadata` forwarding in 
`B2Backend::presign`, updated `test_presign_write_b2_headers`, and ran the 
baseline and candidate live Backblaze B2 trials.
   - **Harness:** Pi (via T3 Code)
     **Model:** `magpie/codex/gpt-6.2-sol`
     **Effort:** `high`
     **Role:** Independently reviewed the signed candidate (`41d88cec51`), 
header test coverage, and live verification evidence.
   - **Harness:** Pi (via T3 Code)
     **Model:** `magpie/codex/gpt-6.2-astra`
     **Effort:** `high`
     **Role:** Coordinated scope triage for #6274 and reviewed verification 
evidence.
   - **Harness:** Pi (via T3 Code)
     **Model:** Gemini 4 Neon
     **Effort:** `high`
     **Role:** Verified publication preflight checks (commit signature, tree, 
base alignment, duplicate PRs, and CI queue status), drafted this PR 
description from the signed commit and sanitized evidence record, and published 
the PR. Assumptions/unknowns affecting review: the committed behavior test 
checks only returned presigned request headers, while persisted metadata, file 
ID, and byte round-trip checks ran in a separate live single-object Backblaze 
B2 trial.
   


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