-
-
Notifications
You must be signed in to change notification settings - Fork 200
Open
Description
Describe the bug
When calling client.receive_message()
with MaxNumberOfMessages
> 1, the message in the queue is duplicated in the response.
To clarify, this is not an SQS duplication issue from AWS; the duplicate count matches the value of MaxNumberOfMessages
up to 5. Here is a basic example.
Please set QUEUE_URL to an SQS queue. Also, please note that I clear this queue before running the test.
import asyncio
from aiobotocore.session import get_session
QUEUE_URL = ""
async def main():
session = get_session()
async with session.create_client("sqs") as client:
# Purge the queue to start clean
print("Purging queue...")
await client.purge_queue(QueueUrl=QUEUE_URL)
await asyncio.sleep(3) # Give AWS a moment to process purge
# Confirm no messages
attrs = await client.get_queue_attributes(
QueueUrl=QUEUE_URL, AttributeNames=["ApproximateNumberOfMessages"]
)
print("Initial message count:", attrs["Attributes"]["ApproximateNumberOfMessages"])
# Send 1 message
print("Sending 1 message...")
await client.send_message(QueueUrl=QUEUE_URL, MessageBody="Test message")
await asyncio.sleep(2) # Wait for it to be visible
# Pull messages with MaxNumberOfMessages=2
print("Receiving messages with MaxNumberOfMessages=2...")
resp = await client.receive_message(
QueueUrl=QUEUE_URL,
MaxNumberOfMessages=4,
WaitTimeSeconds=1,
)
messages = resp.get("Messages", [])
print(f"Received {len(messages)} message(s):", [m["MessageId"] for m in messages])
assert len(messages) == 1, "Expected to receive 1 message, but got something else!"
if __name__ == "__main__":
asyncio.run(main())
Checklist
- I have reproduced in environment where
pip check
passes without errors - I have provided
pip freeze
results - I have provided sample code or detailed way to reproduce
- I have tried the same code in botocore to ensure this is an aiobotocore specific issue
- I have tried similar code in aiohttp to ensure this is is an aiobotocore specific issue
- I have checked the latest and older versions of aiobotocore/aiohttp/python to see if this is a regression / injection
pip freeze results
aiobotocore==2.23.0
aiohappyeyeballs==2.6.1
aiohttp==3.12.13
aioitertools==0.12.0
aiosignal==1.4.0
attrs==25.3.0
botocore==1.38.27
frozenlist==1.7.0
idna==3.10
jmespath==1.0.1
multidict==6.6.3
propcache==0.3.2
python-dateutil==2.9.0.post0
six==1.17.0
urllib3==2.5.0
wrapt==1.17.2
yarl==1.20.1
Environment:
- Python Version: 3.13
- OS name and version: Darwin Kernel Version 24.5.0
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
No labels