Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bug: published message on sns not received when it contains an empty array #12752

Open
@a-jaouen

Description

@a-jaouen

Is there an existing issue for this?

  • 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

Metadata

Metadata

Assignees

Labels

aws:snsAmazon Simple Notification Servicestatus: response requiredWaiting for a response from the reportertype: bugBug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions