Admiral-Piett / goaws

AWS (SQS/SNS) Clone for Development testing
MIT License
788 stars 146 forks source link

GoAWS sends empty MessageAttributes & MD5OfMessageAttributes when none are supplied, breaking compatibiltiy with aws/aws-sdk-php #328

Open zikeji opened 1 month ago

zikeji commented 1 month ago

Relevant issue: https://github.com/aws/aws-sdk-php/issues/2827

When creating a message with no attributes, the message returned by receive message has an empty MessageAttributes object and a empty string for MD5OfMessageAttributes.

This can be reproduced with:

aws sqs send-message --queue-url http://goaws:4100/100010001000/default --message-body "test"
# {
#    "MD5OfMessageBody": "098f6bcd4621d373cade4e832627b4f6",
#    "MD5OfMessageAttributes": "",
#    "MessageId": "d9e27ccb-bbd7-4569-b00f-a6f6d91bdb37",
#    "SequenceNumber": ""
# }
aws sqs receive-message --queue-url http://goaws:4100/100010001000/default
# {
#    "Messages": [
#        {
#            "MessageId": "d9e27ccb-bbd7-4569-b00f-a6f6d91bdb37",
#            "ReceiptHandle": "d9e27ccb-bbd7-4569-b00f-a6f6d91bdb37#94880fdc-9092-4ef4-bbf6d950b2ddc966",
#            "MD5OfBody": "098f6bcd4621d373cade4e832627b4f6",
#            "Body": "test",
#            "Attributes": {
#                "ApproximateFirstReceiveTimestamp": "1729637818936",
#                "ApproximateReceiveCount": "1",
#                "SenderId": "100010001000",
#                "SentTimestamp": "1729637818936"
#            },
#            "MD5OfMessageAttributes": "",
#            "MessageAttributes": {}
#        }
#    ]
# }
kojisaikiAtSony commented 3 weeks ago

It is related with jackson-ize process with empty map in go 🤔 We may need to add a condition somewhere to prevent map from being made carelessly.

Admiral-Piett commented 3 weeks ago

@zikeji I maaaay have gotten this with the 0.5.1 release. Would you mind checking when you have time and letting me know what you find? Thank you!

zikeji commented 3 weeks ago

@Admiral-Piett Thanks for taking a look! Looks like half of it was resolved, the MessageAttributes property is no longer there as expected, however as MD5OfMessageAttributes is still present and an empty string it's still failing in aws-sdk-php.

Admiral-Piett commented 3 weeks ago

@zikeji Got it. I thought that might happen, but wanted to make sure I was on the right track. I think this should take care of it - https://github.com/Admiral-Piett/goaws/pull/335. I'll get it in v0.5.2!