fix(services/s3): support write if-none-match#7440
Conversation
|
Cross-review from staging regression team (Mika). Local validation passed:
The change correctly prioritizes explicit |
TennyZhuang
left a comment
There was a problem hiding this comment.
Cross-review from @clara-claude-pyreview-719124 (Python bindings / staging regression).
Capability wiring — write_with_if_none_match: true is unconditional, which is correct: unlike write_with_if_match there's no config knob to disable it, and S3 supports it universally. The Python binding's Capability struct will surface this flag automatically since it maps all fields from Rust core.
Request construction — the else if precedence (if_none_match wins over if_not_exists) is consistent with how if_match/if_none_match interact elsewhere in the core. Silent precedence is fine here since callers setting both is a misuse.
Refactor — extracting s3_complete_multipart_upload_request as a sync builder returning Result<Request<Buffer>> is the right call for testability and mirrors the s3_put_object_request pattern cleanly.
Tests — three focused request-construction tests cover the new path, the existing if_not_exists: * fallback, and the multipart case. Good coverage for the surface area changed.
Doc fix — removing the S3-specific note from WriteOptions::if_none_match is accurate now.
No issues from the Python binding side. LGTM.
7c6f1d9 to
0cd146b
Compare
0cd146b to
e79a9c1
Compare
Which issue does this PR close?
Closes #7419.
Rationale for this change
OpenDAL exposes
OpWrite::if_none_match, but the S3 backend only emittedIf-None-Match: *for the specialif_not_existscase. S3 supports conditional writes throughIf-None-Matchon both PutObject and CompleteMultipartUpload, so callers should be able to use the general option when the backend advertises it.What changes are included in this PR?
Capability::write_with_if_none_matchfor S3.If-None-Matchon PutObject requests.If-None-Matchon CompleteMultipartUpload requests.if_not_existsbehavior as theIf-None-Match: *fallback.Validation:
I also tried
cargo test -p opendal-service-s3; the new tests passed, but the existingbackend::tests::test_detect_regionfailed locally because live region detection forhttps://s3.amazonaws.comreturnedNoneinstead ofSome("us-east-1"), which is unrelated to this header construction change.Are there any user-facing changes?
No API change. S3 now honors an already exposed conditional-write option.
AI Usage Statement
This PR was prepared with AI assistance from OpenAI Codex (GPT-5), supervised by @TennyZhuang in the staging regression workflow.