Skip to content

bug: SNS batch entry IDs are not correctly validated #13526

@krlxgrn

Description

@krlxgrn

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

SNS has some validation on the entry ids in batch publish requests including allowed characters and length: https://docs.aws.amazon.com/sns/latest/api/API_PublishBatchRequestEntry.html

LocalStack does not currently perform this validation

awslocal sns publish-batch --topic-arn "arn:aws:sns:us-east-1:112233445566:my-topic-local" --publish-batch-request-entries '[{"Id": "message.id", "Message": "{}"}]'
{
    "Successful": [
        {
            "Id": "message.id",
            "MessageId": "3a6c4dfe-2329-47a7-a8aa-905abdc04a43"
        }
    ],
    "Failed": []
}

awslocal sns publish-batch --topic-arn "arn:aws:sns:us-east-1:112233445566:my-topic-local" --publish-batch-request-entries '[{"Id": "myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongid", "Message": "{}"}]'
{
    "Successful": [
        {
            "Id": "myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongid",
            "MessageId": "cf07aa73-9357-427d-b2b0-f15b3eb76c82"
        }
    ],
    "Failed": []
}

Expected Behavior

Publishing in AWS gives these errors:

aws sns publish-batch --topic-arn "arn:aws:sns:eu-west-2:*:my-topic" --publish-batch-request-entries '[{"Id": "my.message.id", "Message": "{}"}]'

An error occurred (InvalidBatchEntryId) when calling the PublishBatch operation: The Id of a batch entry in the batch request contains an impermissible character: my.message.id

aws sns publish-batch --topic-arn "arn:aws:sns:eu-west-2:*:my-topic" --publish-batch-request-entries '[{"Id": "myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongid", "Message": "{}"}]'

An error occurred (InvalidBatchEntryId) when calling the PublishBatch operation: The Id of a batch entry in the batch request is too long: myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongid

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

services:
  localstack:
    image: localstack/localstack:4.12.0
    container_name: localstack
    environment:
      - DEBUG=1
      - LS_LOG=info
      - SERVICES=events,lambda,s3,secretsmanager,sns,sqs
      - HOSTNAME=localstack
      - LAMBDA_REMOVE_CONTAINERS=false
    volumes:
      - ./images/localstack:/etc/localstack/init/ready.d
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - '4566:4566'

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

awslocal sns create-topic --name my-topic-local
awslocal sns publish-batch --topic-arn "arn:aws:sns:us-east-1:112233445566:my-topic-local" --publish-batch-request-entries '[{"Id": "message.id", "Message": "{}"}]'

Environment

- OS: macOS 15.6.1
- LocalStack:
  LocalStack version: 4.12.0
  LocalStack build date: 2025-12-11
  LocalStack build git hash: b570b3ee2

Anything else?

Similar to #7312

Metadata

Metadata

Assignees

No one assigned

    Labels

    aws:snsAmazon Simple Notification Servicestatus: backlogTriaged but not yet being worked ontype: bugBug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions