Admiral-Piett / goaws

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

SQS Message Attributes #233

Closed vaughanbrittonsage closed 2 years ago

vaughanbrittonsage commented 3 years ago

SQS message attributes are not populated from SNS message attributes.

When publishing a message to an SNS topic with message attributes, the message attributes are not passed into the message that is sent to the subscribed SQS queue.

sweatybridge commented 3 years ago

I can confirm this issue. The message attributes are wrapped inside Body field as a serialised json string which is not compliant with the documented response format for boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sqs.html#SQS.Client.receive_message

{
    "MessageId": "51c05a3e-e01f-436c-9fa5-2ae7e2e8cf8c",
    "ReceiptHandle": "51c05a3e-e01f-436c-9fa5-2ae7e2e8cf8c#2eec18b8-ff9e-4da7-813e-2a872ccd30ef",
    "MD5OfBody": "549cfca570cf3ba67bedffe8645e528d",
    "Body": {
        "Type": "Notification",
        "Token": "",
        "MessageId": "25a5abd8-8d0e-4167-b6f0-0f84f49f737c",
        "TopicArn": "arn:aws:sns:ap-southeast-1:100010001000:test-topic",
        "Subject": "",
        "Message": "data",
        "Timestamp": "2021-05-28T07:06:31Z",
        "SignatureVersion": "1",
        "Signature": "Q+URKFSue8KEbyWyatY6rwrFCkqucgJqoju/FBoqWzKMxSDBejshXIA/wPDRdLHqLuKgkzuMON584AKHqsK8s16cFsS4h2Uznv9ODQ+xnNMGyhAjPzBBpQBxe7mLzFw+J41GXyRKLrq9v2XOr7BtduGFJ62NEZbMkgpoZpAl7xKxevoh4VL0rrOIjQBl6R1V7nwW+cVngbJZDqV4tYZ8lj1pJ5w0InwfEKIiZRL7brsqgIjfUG/+o09E4DczTQ7IYkoQrrh7MXCCijCDR0FqE3lBfUMV8agOpcclx0lVLfuL2NEqXydPs0ttvbhwKcolBcrsB8J33rcqKNk63ddQ7w==",
        "SigningCertURL": "http://goaws:4100/SimpleNotificationService/25a5abd8-8d0e-4167-b6f0-0f84f49f737c.pem",
        "UnsubscribeURL": "http://goaws:4100/?Action=Unsubscribe\\u0026SubscriptionArn=arn:aws:sns:ap-southeast-1:100010001000:test-topic:2b1d0649-2c8e-46cc-8a25-dd3232bd1635",
        "SubscribeURL": "",
        "MessageAttributes": {
            "data": {
                "Type": "BinaryValue",
                "Value": "AMh7InN0YXR1cyI6InN1Y2Nlc3MiLCJkYXRhIjp7InJlc3VsdFR5cGUiOiJ2ZWN0b3IiLCJyZXN1bHQiOltdfX0="
            },
            "request_id": {
                "Type": "StringValue",
                "Value": "b27b35f7-4f9c-4998-bc36-6076e0f18f56"
            }
        }
    },
    "Attributes": {
        "ApproximateFirstReceiveTimestamp": "1622185591",
        "SenderId": "100010001000",
        "ApproximateReceiveCount": "1",
        "SentTimestamp": "1622185591"
    }
}

EDIT: I suspect it has something to do with raw message delivery when subscriptions are created via API instead of yaml config. @p4tin I'd be happy to submit a PR if you can explain in more details how this is handled in the backend.

sweatybridge commented 3 years ago

Turns out the docker hub image is outdated. It's now working as expected with an image built from source.