From 8f5a6e3b0a0699d141ddc2ddb090696f36f148b5 Mon Sep 17 00:00:00 2001 From: Florence Date: Wed, 22 Apr 2026 13:22:50 +0900 Subject: [PATCH 1/2] Fix SQS CreateQueue type error by casting attributes to string --- providers/amazon/src/airflow/providers/amazon/aws/hooks/sqs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/amazon/src/airflow/providers/amazon/aws/hooks/sqs.py b/providers/amazon/src/airflow/providers/amazon/aws/hooks/sqs.py index f813e6cee5a6d..3740113635504 100644 --- a/providers/amazon/src/airflow/providers/amazon/aws/hooks/sqs.py +++ b/providers/amazon/src/airflow/providers/amazon/aws/hooks/sqs.py @@ -52,7 +52,8 @@ def create_queue(self, queue_name: str, attributes: dict | None = None) -> dict: :return: dict with the information about the queue. """ self.log.debug("Creating SQS queue %s with attributes %s", queue_name, attributes) - result = self.get_conn().create_queue(QueueName=queue_name, Attributes=attributes or {}) + safe_attributes = {k: str(v) for k, v in (attributes or {}).items()} + result = self.get_conn().create_queue(QueueName=queue_name, Attributes=safe_attributes or {}) self.log.debug("Created SQS queue %s, response: %s", queue_name, result.get("QueueUrl")) return result From cc56b5a43784a7116b6ef401ece1cf9ed02648cf Mon Sep 17 00:00:00 2001 From: Florence Date: Wed, 22 Apr 2026 16:23:19 +0900 Subject: [PATCH 2/2] test: add unit test for SqsHook.create_queue attribute casting --- .../tests/unit/amazon/aws/hooks/test_sqs.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/providers/amazon/tests/unit/amazon/aws/hooks/test_sqs.py b/providers/amazon/tests/unit/amazon/aws/hooks/test_sqs.py index c4c1cb29dc4d5..fa66a437b9e68 100644 --- a/providers/amazon/tests/unit/amazon/aws/hooks/test_sqs.py +++ b/providers/amazon/tests/unit/amazon/aws/hooks/test_sqs.py @@ -145,6 +145,29 @@ def test_send_message_with_delay(self, hook): immediate_receive = hook.get_conn().receive_message(QueueUrl=self.queue_url, WaitTimeSeconds=0) assert "Messages" not in immediate_receive or len(immediate_receive.get("Messages", [])) == 0 + def test_create_queue_with_int_attributes(self, hook): + """Test that int attribute values are internally cast to strings and queue creation succeeds.""" + queue_name = "test-queue-int-casting" + # These are the int values that the casting logic (fixed in SqsHook) should handle. + attributes = { + "DelaySeconds": 10, + "MaximumMessageSize": 262144, + } + + response = hook.create_queue(queue_name=queue_name, attributes=attributes) + + assert "QueueUrl" in response + assert queue_name in response["QueueUrl"] + + # Verify that the attributes were correctly cast and stored as strings in the SQS service (moto). + queue_attrs = hook.get_conn().get_queue_attributes( + QueueUrl=response["QueueUrl"], AttributeNames=["DelaySeconds", "MaximumMessageSize"] + ) + + # moto/boto3 returns values as strings; if these assertions pass, the casting logic is verified. + assert queue_attrs["Attributes"]["DelaySeconds"] == "10" + assert queue_attrs["Attributes"]["MaximumMessageSize"] == "262144" + @pytest.mark.asyncio class TestAsyncSqsHook: