Support conditional writes (If-Match / If-None-Match) on PutObject and CopyObject - #294
Open
Robothy wants to merge 2 commits into
Open
Support conditional writes (If-Match / If-None-Match) on PutObject and CopyObject#294Robothy wants to merge 2 commits into
Robothy wants to merge 2 commits into
Conversation
…d CopyObject Evaluate the If-Match and If-None-Match headers before writing to storage so that a failed precondition never leaves a dangling object behind. The check is applied in a single place, PutObjectService#putObject, which CopyObject and CompleteMultipartUpload both route through. ETag comparison tolerates both quoted and unquoted values, since clients echo back the ETag returned by the server verbatim. Closes #289
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #294 +/- ##
============================================
- Coverage 90.76% 90.75% -0.01%
- Complexity 1459 1479 +20
============================================
Files 248 250 +2
Lines 5327 5365 +38
Branches 399 407 +8
============================================
+ Hits 4835 4869 +34
- Misses 338 340 +2
- Partials 154 156 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #289
What
Adds support for the S3 conditional write headers on
PutObject,CopyObjectandCompleteMultipartUpload:If-Match-- write only if the current ETag matches (*requires the object to exist)If-None-Match-- write only if the current ETag does not match (*requires the object to be absent)Returns
412 PreconditionFailedwhen a condition does not hold. Reuses the existingS3ErrorCode.PreconditionFailed, no new error code.How
The check happens in a single place --
PutObjectService#putObject, before content is written to storage, so a failed precondition never leaves a dangling object.CopyObjectandCompleteMultipartUploadboth route through it and pass the headers along.ETag comparison tolerates both quoted and unquoted values, because clients echo back the ETag returned by the server verbatim (the server returns
"<hex>").Tests
New
ConditionalRequestIntegrationTestwith 8 cases covering wildcard and explicit ETags, match/mismatch on both headers, quoted ETags from the server, CopyObject, and 404 precedence on a missing bucket.Full suite: 640 tests, 0 failures (baseline 632 + 8 new).