Check SQS message size
This commit is contained in:
parent
ab3682a55c
commit
5b2a724219
@ -11,6 +11,11 @@ class ReceiptHandleIsInvalid(Exception):
|
||||
status_code = 400
|
||||
|
||||
|
||||
class InvalidParameterValue(Exception):
|
||||
description = "One or more parameters are invalid. Reason: Message must be shorter than 262144 bytes."
|
||||
status_code = 400
|
||||
|
||||
|
||||
class MessageAttributesInvalid(Exception):
|
||||
status_code = 400
|
||||
|
||||
|
@ -12,7 +12,8 @@ from moto.core.utils import camelcase_to_underscores, get_random_message_id
|
||||
from .utils import generate_receipt_handle, unix_time_millis
|
||||
from .exceptions import (
|
||||
ReceiptHandleIsInvalid,
|
||||
MessageNotInflight
|
||||
MessageNotInflight,
|
||||
InvalidParameterValue,
|
||||
)
|
||||
|
||||
DEFAULT_ACCOUNT_ID = 123456789012
|
||||
@ -251,6 +252,9 @@ class SQSBackend(BaseBackend):
|
||||
else:
|
||||
delay_seconds = queue.delay_seconds
|
||||
|
||||
if len(message_body) > self.maximum_message_size:
|
||||
raise InvalidParameterValue
|
||||
|
||||
message_id = get_random_message_id()
|
||||
message = Message(message_id, message_body)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user