InvalidParameterValue aws protocol_error ai_generated true

An error occurred (InvalidParameterValue) when calling the SendMessage operation: One or more parameter values are invalid. Message attributes size must be smaller than 25600 bytes

ID: aws/sqs-message-attributes-too-large

Also available as: JSON · Markdown · 中文
92%Fix Rate
86%Confidence
1Evidence
2023-08-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
sqs-2024 active
aws-sdk-python-1.34.0 active

Root Cause

The total size of message attributes (including keys and values) exceeds the 25 KB limit for SQS messages.

generic

中文

消息属性的总大小(包括键和值)超过了SQS消息的25 KB限制。

Official Documentation

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-quotas.html

Workarounds

  1. 95% success Move large attributes (e.g., binary data, large strings) to the message body instead. The body has a 256 KB limit. Example: sqs_client.send_message(QueueUrl=queue_url, MessageBody=json.dumps({'data': large_data}), MessageAttributes={'attr1': {'DataType': 'String', 'StringValue': 'small_value'}})
    Move large attributes (e.g., binary data, large strings) to the message body instead. The body has a 256 KB limit. Example: sqs_client.send_message(QueueUrl=queue_url, MessageBody=json.dumps({'data': large_data}), MessageAttributes={'attr1': {'DataType': 'String', 'StringValue': 'small_value'}})
  2. 90% success If attributes are necessary, store large attribute values in S3 or DynamoDB and pass only a reference (e.g., S3 key) as the attribute value.
    If attributes are necessary, store large attribute values in S3 or DynamoDB and pass only a reference (e.g., S3 key) as the attribute value.

中文步骤

  1. Move large attributes (e.g., binary data, large strings) to the message body instead. The body has a 256 KB limit. Example: sqs_client.send_message(QueueUrl=queue_url, MessageBody=json.dumps({'data': large_data}), MessageAttributes={'attr1': {'DataType': 'String', 'StringValue': 'small_value'}})
  2. If attributes are necessary, store large attribute values in S3 or DynamoDB and pass only a reference (e.g., S3 key) as the attribute value.

Dead Ends

Common approaches that don't work:

  1. 90% fail

    SQS检查的是未压缩的属性大小,压缩不会改变原始大小。

  2. 100% fail

    FIFO队列与标准队列具有相同的属性大小限制。