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
Simulate S3 BadDigest and InvalidDigest errors #2562
Comments
Thanks for reporting @charleswhchan . Not sure I fully understand your use case - can you please elaborate a bit? I think it should already be possible to pass the localstack/localstack/services/s3/s3_listener.py Lines 706 to 714 in a60eb05
|
Hi @whummer, thanks for looking into this. What I am trying to do is write a test to write to S3 with localstack and produce conditions that would lead to BadDigest and InvalidDigest errors. This is so that I can check the error handling is working correctly in my code. Based on my understanding of the AWS REST API. Does this help? |
Ok, thanks for the clarification @charleswhchan . This should be fixed in #2592 - can you please give it a try with the |
Hi @whummer. I just tried the I am using go-lang, and here are my 2 test cases: Test 1.
Test 2
Note: I also run the same test against S3 and MinIO to to confirm the expected behaviour. |
Hi @charleswhchan , thanks for the update. Haven't been able to reproduce this issue, unfortunately. We've added an extended set of tests here which tests for both - InvalidDigest and BadDigest errors: https://github.com/localstack/localstack/blob/master/tests/integration/test_s3.py#L698-L715 Can you please post an isolated, self-contained example code snippet that can be directly executed to reproduce the issue you're facing? Thanks |
Hi @whummer : I really appreciate your effort in troubleshooting this issue 👍 After reviewing your tests and comparing to my test, I found something interesting that triggers the error. I have created a gist Specifically, if you refer to the checksum used in Test #3:
Output
I did a bit more investigation and it appears it might have to something with the length of the Strange problem. I hope this information helps 😃 |
Thanks for the update @charleswhchan , we were able to reproduce this issue based on the gist you provided. 👍 The issue was related to whitespaces. Coincidentally, the digest string you were using for testing is technically a valid base64 encoded string, if your strip off the whitespaces:
If you add one more character, then the string is not valid base64 anymore:
This should be now (finally) fixed in #2635 - we are now considering whitespaces as illegal base64 encoding. Please report here if the problem persists with the |
Thanks @whummer, I can confirm with the latest image, the I did mention another case in my last post (not in gist): |
Type of request: This is a ...
[ ] bug report
[x] feature request
Detailed description
As a Developer,
I want to be able to simulate BadDigest and InvalidDigest errors,
So that I can test the error handling logic
Expected behavior
https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
BadDigest: The Content-MD5 you specified did not match what we received.
InvalidDigest: The Content-MD5 you specified is not valid.
Actual behavior
localstack returns InvalidDigest when MD5 does not match payload.
The text was updated successfully, but these errors were encountered: