-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Can not PUT a 0 bytes object when Object Lock is enabled on s3 bucket #1979
Comments
Thank you for your post. I am not able to reproduce the issue with a Object Lock enabled s3 bucket. Can you please give me a code sample to reproduce the issue ? I have tested with this code: s3 = boto3.client('s3')
data = ''
res = s3.put_object(Bucket = 'bucketname', Body=data, Key='emptyfile.txt') It would be helpful if you could provide me debug logs as well. You can enable logs by adding |
Hi @swetashre thank you for the prompt response. It seems you're correct this doesn't occur with
|
I am not able to reproduce the issue with |
Here is the log. I have search/replaced the actual bucket name with
|
I put a breakpoint in botocore (within
Issue is fixed with this patch:
|
@wimglenn - I have not correctly configured the retention period that's why i was not getting error. After configured it correctly i am able to reproduce the issue. |
@swetashre Any update on this? We are limping along with a locally patched botocore for the moment. |
@swetashre we're experiencing the same issue. Any chance to the the fix from @wimglenn merged, please? |
* Include Content-MD5 header even when body is empty. Closes #1979
|
When uploading an empty file to an s3 bucket which has object lock enabled:
The API requires this header, but in botocore it does not inject it, I think problem is probably here within the handler for
before-call.s3.PutObject
:https://github.com/boto/botocore/blame/1aac4d7c1f311826a1a4686e54444f6ded72ea45/botocore/handlers.py#L187-L196
Look at the if-statement:
It neglects the possibility that
request_dict["body"]
is empty.For >= 1 bytes files,
content-md5
gets automatically set and upload succeeds.The text was updated successfully, but these errors were encountered: