diff --git a/localstack-core/localstack/services/sqs/models.py b/localstack-core/localstack/services/sqs/models.py index cf08f905ad07b..759de9ecc82cc 100644 --- a/localstack-core/localstack/services/sqs/models.py +++ b/localstack-core/localstack/services/sqs/models.py @@ -748,9 +748,9 @@ def put( f"Value {message_deduplication_id} for parameter MessageDeduplicationId is invalid. Reason: The " f"request includes a parameter that is not valid for this queue type." ) - if message_group_id: + if isinstance(message_group_id, str): raise InvalidParameterValueException( - f"Value {message_group_id} for parameter MessageGroupId is invalid. Reason: The request includes a " + f"Value {message_group_id} for parameter MessageGroupId is invalid. Reason: The request include " f"parameter that is not valid for this queue type." ) diff --git a/tests/aws/services/sqs/test_sqs.py b/tests/aws/services/sqs/test_sqs.py index 2903612e58e73..c89a56a374e3e 100644 --- a/tests/aws/services/sqs/test_sqs.py +++ b/tests/aws/services/sqs/test_sqs.py @@ -436,6 +436,16 @@ def test_send_message_batch_with_oversized_contents_with_updated_maximum_message snapshot.match("send_oversized_message_batch", response) + @markers.aws.validated + def test_send_message_to_standard_queue_with_empty_message_group_id( + self, sqs_create_queue, aws_client, snapshot + ): + queue = sqs_create_queue() + + with pytest.raises(ClientError) as e: + aws_client.sqs.send_message(QueueUrl=queue, MessageBody="message", MessageGroupId="") + snapshot.match("error-response", e.value.response) + @markers.aws.validated def test_tag_untag_queue(self, sqs_create_queue, aws_sqs_client, snapshot): queue_url = sqs_create_queue() diff --git a/tests/aws/services/sqs/test_sqs.snapshot.json b/tests/aws/services/sqs/test_sqs.snapshot.json index 5eb3d5dba7530..f29f5b16cb4b1 100644 --- a/tests/aws/services/sqs/test_sqs.snapshot.json +++ b/tests/aws/services/sqs/test_sqs.snapshot.json @@ -974,6 +974,23 @@ } } }, + "tests/aws/services/sqs/test_sqs.py::TestSqsProvider::test_send_message_to_standard_queue_with_empty_message_group_id": { + "recorded-date": "08-11-2024, 12:04:39", + "recorded-content": { + "error-response": { + "Error": { + "Code": "InvalidParameterValue", + "Message": "Value for parameter MessageGroupId is invalid. Reason: The request include parameter that is not valid for this queue type.", + "QueryErrorCode": "InvalidParameterValueException", + "Type": "Sender" + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, "tests/aws/services/sqs/test_sqs.py::TestSqsProvider::test_send_batch_missing_message_group_id_for_fifo_queue[sqs_query]": { "recorded-date": "30-04-2024, 13:33:45", "recorded-content": { diff --git a/tests/aws/services/sqs/test_sqs.validation.json b/tests/aws/services/sqs/test_sqs.validation.json index 291ae1067b444..d697e29bddca7 100644 --- a/tests/aws/services/sqs/test_sqs.validation.json +++ b/tests/aws/services/sqs/test_sqs.validation.json @@ -269,6 +269,9 @@ "tests/aws/services/sqs/test_sqs.py::TestSqsProvider::test_send_message_batch_with_oversized_contents_with_updated_maximum_message_size[sqs_query]": { "last_validated_date": "2024-04-30T13:33:10+00:00" }, + "tests/aws/services/sqs/test_sqs.py::TestSqsProvider::test_send_message_to_standard_queue_with_empty_message_group_id": { + "last_validated_date": "2024-11-08T12:08:17+00:00" + }, "tests/aws/services/sqs/test_sqs.py::TestSqsProvider::test_send_message_with_binary_attributes[sqs]": { "last_validated_date": "2024-04-30T13:33:48+00:00" },