This is an automated email from the ASF dual-hosted git repository.
shahar1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ba3da41e806 Fix SQS CreateQueue type error by casting attributes to
string (#65649)
ba3da41e806 is described below
commit ba3da41e80652fbd4d5dec8d05dc8d734a0c64a9
Author: Florence <[email protected]>
AuthorDate: Thu Apr 23 01:09:25 2026 +0900
Fix SQS CreateQueue type error by casting attributes to string (#65649)
---
.../src/airflow/providers/amazon/aws/hooks/sqs.py | 3 ++-
.../amazon/tests/unit/amazon/aws/hooks/test_sqs.py | 23 ++++++++++++++++++++++
2 files changed, 25 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 f813e6cee5a..37401136355 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 @@ class SqsHook(AwsBaseHook):
: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
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 c4c1cb29dc4..fa66a437b9e 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 @@ class TestSqsHook:
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: