-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: implement conditional headers for S3 CopyObject API #13554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
localstack-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
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