Merge pull request #1667 from iainb/enforce-message-size
SNS - Enforce 'Message too long' exception when publishing messages
This commit is contained in:
commit
db4c84c680
2 changed files with 19 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ from .utils import make_arn_for_topic, make_arn_for_subscription
|
|||
|
||||
DEFAULT_ACCOUNT_ID = 123456789012
|
||||
DEFAULT_PAGE_SIZE = 100
|
||||
MAXIMUM_MESSAGE_LENGTH = 262144 # 256 KiB
|
||||
|
||||
|
||||
class Topic(BaseModel):
|
||||
|
|
@ -327,6 +328,9 @@ class SNSBackend(BaseBackend):
|
|||
# Note that the AWS docs around length are wrong: https://github.com/spulec/moto/issues/1503
|
||||
raise ValueError('Subject must be less than 100 characters')
|
||||
|
||||
if len(message) > MAXIMUM_MESSAGE_LENGTH:
|
||||
raise InvalidParameterValue("An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: Message too long")
|
||||
|
||||
try:
|
||||
topic = self.get_topic(arn)
|
||||
message_id = topic.publish(message, subject=subject,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue