bug: published message on sns not received when it contains an empty array
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
I have an SNS topic publishing on an SQS queue defining a filter policy. When publishing a JSON message containing an empty array the message is published correctly but never received on the consumer side. The exact same configuration with AWS managed SNS and SQS services have the message delivered to the consumer correctly.
Expected Behavior
The message should be delivered to the consumer correctly
How are you starting LocalStack?
With a docker-compose file
Steps To Reproduce
Run localstack via docker-compose.yml
version: '3'
services:
localstack:
image: localstack/localstack:3
restart: unless-stopped
ports:
- 4566:4566
Then run docker compose up -d
Create the topic and queue
# Create SNS topic
aws --endpoint-url=http://localhost:4566 sns create-topic \
--name my-topic.fifo \
--attributes FifoTopic=true,ContentBasedDeduplication=true
# Create SQS queue
aws --endpoint-url=http://localhost:4566 sqs create-queue \
--queue-name my-queue.fifo \
--attributes FifoQueue=true,ContentBasedDeduplication=true
# Get the ARN for the SNS topic
TOPIC_ARN=$(aws --endpoint-url=http://localhost:4566 sns list-topics \
--query "Topics[?contains(TopicArn, 'my-topic.fifo')].TopicArn" \
--output text)
# Get the ARN for the SQS queue
QUEUE_ARN=$(aws --endpoint-url=http://localhost:4566 sqs get-queue-attributes \
--queue-url http://localhost:4566/000000000000/my-queue.fifo \
--attribute-name QueueArn \
--query "Attributes.QueueArn" \
--output text)
# Subscribe SQS queue to SNS topic with filter policy
aws --endpoint-url=http://localhost:4566 sns subscribe \
--topic-arn arn:aws:sns:us-east-2:000000000000:my-topic.fifo \
--protocol sqs \
--notification-endpoint arn:aws:sqs:us-east-2:000000000000:my-queue.fifo \
--attributes '{
"FilterPolicy": "{\"eventType\":[\"MyEventType\"]}",
"FilterPolicyScope": "MessageBody",
"RawMessageDelivery": "true"
}'
Publish a message containing an empty array
aws --endpoint-url=http://localhost:4566 sns publish \
--region us-east-2 \
--topic-arn arn:aws:sns:us-east-2:000000000000:my-topic.fifo \
--message '{"eventType": "MyEventType", "field": []}' \
--message-group-id "123" \
--message-deduplication-id "$RANDOM"
Receive the message
aws --endpoint-url=http://localhost:4566 sqs receive-message \
--queue-url http://localhost:4566/000000000000/my-queue.fifo \
--region us-east-2 \
--max-number-of-messages 10 \
--wait-time-seconds 200
The message is never received
Publish a message containing a non-empty array
aws --endpoint-url=http://localhost:4566 sns publish \
--region us-east-2 \
--topic-arn arn:aws:sns:us-east-2:000000000000:my-topic.fifo \
--message '{"eventType": "MyEventType", "field": [1]}' \
--message-group-id "123" \
--message-deduplication-id "$RANDOM"
The message is received this time
Environment
- OS: Ubuntu 20.04
- LocalStack version: 4.5
Anything else?
No response
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Support if you are a licensed user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines.
Hello @a-jaouen and thanks for your report.
I've just given it a try with your reported version, 4.5 and your sample works for me, I believe this issue has been solved.
However, I can see in your Docker compose that you are using localstack/localstack:3, which is an older version. Could you try using 4.5 and see if that solve your issue? Thank you!
Hello @bentsku thank you very much for you answer!
Indeed, it's working. I updated localstack cli but forgot to update the docker image from my docker-compose.
Thanks again!