diff --git a/moto/sqs/responses.py b/moto/sqs/responses.py index 8acea0799..f5481cc10 100644 --- a/moto/sqs/responses.py +++ b/moto/sqs/responses.py @@ -285,6 +285,9 @@ class SQSResponse(BaseResponse): "MessageAttributes": message_attributes, } + if entries == {}: + raise EmptyBatchRequest() + messages = self.sqs_backend.send_message_batch(queue_name, entries) template = self.response_template(SEND_MESSAGE_BATCH_RESPONSE) diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index f2ab8c37c..9deb8d8e2 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -1147,6 +1147,21 @@ def test_send_message_batch_errors(): ) +@mock_sqs +def test_send_message_batch_with_empty_list(): + client = boto3.client("sqs", region_name="us-east-1") + + response = client.create_queue(QueueName="test-queue") + queue_url = response["QueueUrl"] + + client.send_message_batch.when.called_with( + QueueUrl=queue_url, Entries=[] + ).should.throw( + ClientError, + "There should be at least one SendMessageBatchRequestEntry in the request.", + ) + + @mock_sqs def test_batch_change_message_visibility(): if os.environ.get("TEST_SERVER_MODE", "false").lower() == "true":