fake_sqs icon indicating copy to clipboard operation
fake_sqs copied to clipboard

MD5 returned by SQS does not match the calculation on the original request

Open tbhi opened this issue 9 years ago • 12 comments

I'm trying to use a java application with fake_sqs but am getting this:

Caused by: com.amazonaws.AmazonClientException: MD5 returned by SQS does not match the calculation on the original request. (MD5 calculated by the message attributes: "c3d29a3de5c6497a057496fd58a56e89", MD5 checksum returned: "null")
    at com.amazonaws.services.sqs.MessageMD5ChecksumHandler.sendMessageOperationMd5Check(MessageMD5ChecksumHandler.java:120)
    at com.amazonaws.services.sqs.MessageMD5ChecksumHandler.afterResponse(MessageMD5ChecksumHandler.java:80)
    at com.amazonaws.handlers.RequestHandler2Adaptor.afterResponse(RequestHandler2Adaptor.java:49)
    at com.amazonaws.http.AmazonHttpClient.afterResponse(AmazonHttpClient.java:416)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:322)
    at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2419)
    at com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1015)
    at org.apache.camel.component.aws.sqs.SqsProducer.process(SqsProducer.java:58)

I see that one of the ruby examples uses "apiVersion: '2012-11-05'" - perhaps this is required for all clients?

tbhi avatar Nov 19 '15 10:11 tbhi

Any movement on this?

georgepapas avatar Jan 20 '16 03:01 georgepapas

I'm seeing the same issue, any updates?

ssrinivasulu avatar Apr 13 '16 19:04 ssrinivasulu

Also have this problem. fake_sqs doesn't return this at all:

 <SendMessageResponse>
    <SendMessageResult>
        <MD5OfMessageBody>740682d831a40200b5147a683bc1a7d7</MD5OfMessageBody>
        <MessageId>d7a3913a-8c91-4776-b061-dff1c4087a78</MessageId>
    </SendMessageResult>
    <ResponseMetadata>
        <RequestId>dea697d5-fbb5-4c3e-9692-ed27fa1a3d46</RequestId>
    </ResponseMetadata>
</SendMessageResponse>

And when getting the item, the attributes seem to be missing

nathanabercrombie avatar May 05 '16 18:05 nathanabercrombie

Has this project has been abandoned?

algorist avatar Feb 01 '17 09:02 algorist

@algorist No, patches are welcome if this is still an issue.

tiwilliam avatar Aug 11 '17 12:08 tiwilliam

When is this going to be fixed? This is a critical bug. I cannot use fake-sqs to send events in my development whatsoever. The issue is open from November 2015 but still no changes. People have to look for alternatives.

ghost avatar Sep 08 '18 11:09 ghost

Simply when someone decides to take time to fix it. I'm using fake_sqs without hitting this bug. A first good step would be to post code/versions here to re-produce the issue.

tiwilliam avatar Sep 10 '18 09:09 tiwilliam

In Java development, it is not possible to not hit this bug. There is no code sample because it is happening behind the scenes when sending an event is prompted to happen typically in the one line of code. By default, and it can not be changed in Java AWS SQS SDK, before sending a message, SQS verifies the checksum. Fake-sqs returns null instead of valid checksum so the exception is thrown preventing to follow a standard SQS workflow. People don't even try to do something fancy. This bug prevents from testing of message sending - the one and only purpose for which this project was created.

ghost avatar Sep 10 '18 11:09 ghost

I'm in Python land, but I guess this might happen with newer versions of boto3 as well. Send message should send a correct MD5 back, but it obviously doesn't in this case: https://github.com/iain/fake_sqs/blob/master/spec/acceptance/message_actions_spec.rb#L24

Again, if you want me to help you, I would appreciate a SDK version and a code snippet (even if just one line). This way I don't have to spend time, guessing versions, when I also have to setup a Java environment.

tiwilliam avatar Sep 10 '18 15:09 tiwilliam

Does not complain in latest boto3.

Fake:

{
    u 'MD5OfMessageBody': '444bcb3a3fcf8389296c49467f27e1d6', 'ResponseMetadata': {
        'RetryAttempts': 0,
        'HTTPStatusCode': 200,
        'RequestId': '465c6a9a-3b14-4007-a628-fce678fb4280',
        'HTTPHeaders': {
            'content-length': '306',
            'x-xss-protection': '1; mode=block',
            'x-content-type-options': 'nosniff',
            'server': 'WEBrick/1.3.1 (Ruby/2.3.7/2018-03-28)',
            'connection': 'Keep-Alive',
            'date': 'Mon, 10 Sep 2018 15:48:33 GMT',
            'x-frame-options': 'SAMEORIGIN',
            'content-type': 'text/html;charset=utf-8'
        }
    }, u 'MessageId': '30adc959-9e40-4b62-bfa0-bde8ab131501'
}

Real:

{
    u 'MD5OfMessageBody': '444bcb3a3fcf8389296c49467f27e1d6', 'ResponseMetadata': {
        'RetryAttempts': 0,
        'HTTPStatusCode': 200,
        'RequestId': '<obfuscated>',
        'HTTPHeaders': {
            'x-amzn-requestid': '<obfuscated>',
            'content-length': '378',
            'server': 'Server',
            'connection': 'keep-alive',
            'date': 'Mon, 10 Sep 2018 15:50:27 GMT',
            'content-type': 'text/xml'
        }
    }, u 'MessageId': '8f30bb07-cb92-4930-b6e0-ee97bf268ab0'
}

tiwilliam avatar Sep 10 '18 15:09 tiwilliam

I am getting the same issue with aws-java-sdk-sqs 1.11.362 and fake_sqs 0.3.1

volgar1x avatar Mar 15 '19 10:03 volgar1x

FYI: I don't use this library, but I have been struggling with a similar error when using a java client. (I found this by googling my error message). It seems that the java client does two checksums. One for the body and one for the attributes. As I have seen this problem in multiple "SQS Testing Implementations", i'm guessing the java client is doing more work than others? Anyway, calculating the MD5 on the attributes as well as the body seems to be the trick to making the java APIs happy.

phillipgziprecruiter avatar Feb 15 '24 22:02 phillipgziprecruiter