feat: implement conditional headers for S3 CopyObject API#13554
feat: implement conditional headers for S3 CopyObject API#13554bentsku merged 5 commits intolocalstack:mainfrom
Conversation
localstack-bot
left a comment
There was a problem hiding this comment.
Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Thanks a lot for your contribution!
Unfortunately I can see that the tests are not validated against AWS, and thus not following our contribution guidelines. It would be great if you could validate that.
There is also required changes in the CopyObject operation itself, as these conditions headers are there to prevent race conditions, and we do not have concurrency control in your implementation.
As written in the comments, our contribution expectations are pretty high regarding the S3 service as it is one of the most used and a lot of other services depends on it, we're very careful when modifying its behavior. Let me know if you'd need additional help for this one 👍
edit: forgot to add to both PR, it is holidays season here and we might have some delay in reviewing your changes, and might come back to it in January.
…ject for versioned buckets
…h agains aws creds
Hii @bentsku I went through your suggestions and as per my understanding I've made the edits to keep it safe from race conditions (tried mimicking the same logic used in put_object) and also added tests for versioned bucket behavior and also I've ran all those tests against my aws account, I understand the importance of the S3 service, so feel free to suggest any further changes! |
|
Hii @bentsku are there anymore changes required here from my side? |
Hi @shubhiscoding, sorry for the delay here, I still need to do thorough testing and I've been a bit swamped, but will look at it tomorrow and do a review 👍 sorry for the delay again |
There was a problem hiding this comment.
LGTM, great work @shubhiscoding! Sorry I took so long to review this PR, but great work. I took the liberty to push some more changes (only tests) to your branch, in order to validate some scenarios I had in mind that could be problematic or have been in the past with precondition writes. Seems like everything is working perfectly, so I'll approve, and merge once green 👌
Motivation
AWS S3 supports conditional headers (If-Match and If-None-Match) in the CopyObject API to enable atomic copy operations based on the destination object's ETag. LocalStack previously did not support these headers, making it difficult to test applications that rely on conditional copy operations. Fixes #13522
Changes
Implemented support for conditional headers in S3
CopyObjectAPI:If-Matchheader support: Allows copying only if the destination object's ETag matches the specified valueIf-None-Match headersupport: Allows copying only if the destination object doesn't exist (using * wildcard)verify_object_equality_precondition_write) to validate conditions before copy operationThe implementation follows the same pattern as the existing
PutObject conditional header logic.
Tests
Added tests in
test_s3_api.py:test_copy_object_if_none_match: ValidatesIf-None-Match: *behaviorPreconditionFailederror when destination already existstest_copy_object_if_match: ValidatesIf-MatchbehaviorPreconditionFailederror when ETag doesn't matchNoSuchKeyerror when destination doesn't existRelated
#13522