Repository: getmoto/moto

Issue:
sqs: successfull send_message with MessageGroupID on standard queues

According to AWS documentation MessageGroupId is not required for standard queues and if you send it fails with message: 

`botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the SendMessage operation: Value default for parameter MessageGroupId is invalid. Reason: The request include parameter that is not valid for this queue type.`

That doesn't happen when MessageGroupId is sent on a standard queue with moto:

```python

sqs = boto3.client('sqs', region_name=Region)
queue = sqs.create_queue(
    QueueName='input_test_queue',
    Attributes={
        'VisibilityTimeout': '5'
    }
)

queue_url  = queue["QueueUrl"]
sqs.send_message(
            QueueUrl=queue_url,
            MessageBody=json.dumps({}),
            MessageGroupId="MessageGroup"
        )

```

Code above should fail but works successfully.

moto version == 2.0.11




Discussion:
Thanks for raising this @kthristov - marking it as an enhancement to implement this validation

Resolving patch:
diff --git a/moto/sqs/models.py b/moto/sqs/models.py
--- a/moto/sqs/models.py
+++ b/moto/sqs/models.py
@@ -738,6 +738,12 @@ def send_message(
             if queue.fifo_queue:
                 raise MissingParameter("MessageGroupId")
         else:
+            if not queue.fifo_queue:
+                msg = (
+                    "Value {} for parameter MessageGroupId is invalid. "
+                    "Reason: The request include parameter that is not valid for this queue type."
+                ).format(group_id)
+                raise InvalidParameterValue(msg)
             message.group_id = group_id
 
         if message_attributes:


Test patch:
diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py
--- a/tests/test_sqs/test_sqs.py
+++ b/tests/test_sqs/test_sqs.py
@@ -557,6 +557,24 @@ def test_send_message_with_message_group_id():
     message_attributes["MessageDeduplicationId"].should.equal("dedupe_id_1")
 
 
+@mock_sqs
+def test_send_message_with_message_group_id_standard_queue():
+    sqs = boto3.resource("sqs", region_name="us-east-1")
+    queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
+
+    with pytest.raises(ClientError) as ex:
+        queue.send_message(
+            MessageBody="mydata", MessageGroupId="group_id_1",
+        )
+
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidParameterValue")
+    err["Message"].should.equal(
+        "Value group_id_1 for parameter MessageGroupId is invalid. "
+        "Reason: The request include parameter that is not valid for this queue type."
+    )
+
+
 @mock_sqs
 def test_send_message_with_unicode_characters():
     body_one = "Héllo!😀"
@@ -2097,7 +2115,9 @@ def test_delete_message_errors():
 @mock_sqs
 def test_send_message_batch():
     client = boto3.client("sqs", region_name="us-east-1")
-    response = client.create_queue(QueueName=str(uuid4())[0:6])
+    response = client.create_queue(
+        QueueName=f"{str(uuid4())[0:6]}.fifo", Attributes={"FifoQueue": "true"},
+    )
     queue_url = response["QueueUrl"]
 
     response = client.send_message_batch(