Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SQS Delete Batch ID's should be distinct, which MessageID is not guaranteed to be #253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

flipscholtz
Copy link

@flipscholtz flipscholtz commented Aug 25, 2023

When deleting a batch of SQS messages, the Batch ID's have to be unique.
If not, a 'BatchEntryIdsNotDistinct' error is returned and none of the messages are deleted.

Setting this ID equal to the MessageID causes problems because multiple receipts of the same message will have the same MessageID, although it's not the same ReceiptHandle.
For e.g. a single batch may contain:
messageA#receipt1
messageA#receipt2 .
In both cases, the MessageID is messageA but in terms of batched deletion it's two different items.

According to the docs here, the ID passed to DeleteBatch is just a correlation ID, so it can be set to anything user-generated:

Note
The Id s of a batch request need to be unique within a request.

This identifier can have up to 80 characters. The following characters are accepted: alphanumeric characters, hyphens(-), and underscores (_).

So we can just set it to a random UUID to avoid duplicates.

…rwise deleting multiple receipts of the same message results in a 'BatchIDsNotDistinct' error and the whole batch's deletion fails. These batch ID's are just for correlation and can be set to a random UUID.
@flipscholtz flipscholtz force-pushed the fix/sqsDuplicateDeletionBatchIds branch from 8e56c98 to b0e588e Compare August 25, 2023 18:24
@flipscholtz flipscholtz changed the title fix: SQS Delete Batch ID's should not be equal to the MessageID fix: SQS Delete Batch ID's should be distinct, which MessageID is not guaranteed to be Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants