Fix for BatchRequestTooLong exception. (#6550)
A BatchRequestTooLong is thrown by AWS if the length of all the messages put together is greater than the AWS limit. See AWS documentation here: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessageBatch.html#:~:text=Status%20Code%3A%20400-,BatchRequestTooLong,-The%20length%20of. This change if applied determines the sum of all the messages and throws an exception if the AWS limit is exceeded. Co-authored-by: Sophie Cassidy <sophie.cassidy@ly.st>
This commit is contained in:
parent
e3d1ae6815
commit
77a09b71b7
@ -884,15 +884,8 @@ class SQSBackend(BaseBackend):
|
||||
):
|
||||
raise InvalidBatchEntryId()
|
||||
|
||||
body_length = next(
|
||||
(
|
||||
len(entry["MessageBody"])
|
||||
for entry in entries.values()
|
||||
if len(entry["MessageBody"]) > MAXIMUM_MESSAGE_LENGTH
|
||||
),
|
||||
False,
|
||||
)
|
||||
if body_length:
|
||||
body_length = sum(len(entry["MessageBody"]) for entry in entries.values())
|
||||
if body_length > MAXIMUM_MESSAGE_LENGTH:
|
||||
raise BatchRequestTooLong(body_length)
|
||||
|
||||
duplicate_id = self._get_first_duplicate_id(
|
||||
|
Loading…
Reference in New Issue
Block a user