SQS returns uncapitalized dataType, stringValue, but Boto3 requires capitalization
See original GitHub issueWhen using SQS as a Lambda trigger, the MessageAttributes return values with “dataType” and “stringValue”, starting with lower case letters. When trying to send to an SQS queue, Boto3 requires capitalized “DataType” and “StringValue” to be part of the messageAttributes.
This is confusing and I think should be altered, as it looks odd to capitalize differently depending on whether you are sending or receiving a message.
Example: Sent the following to SQS queue
'messageAttributes': {
'startTime': {
'StringValue': '20190929T000000',
'DataType': 'String'
},
'endTime': {
'StringValue': '20191006T000000',
'DataType': 'String'
},
Received the following in the Lambda event
'messageAttributes': {
'startTime': {
'stringValue': '20190929T000000',
'stringListValues': [],
'binaryListValues': [],
'dataType': 'String'
},
'endTime': {
'stringValue': '20191006T000000',
'stringListValues': [],
'binaryListValues': [],
'dataType': 'String'
},
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top Results From Across the Web
class SQS. Client - Boto3 Docs 1.26.31 documentation - AWS
If the queue name, attribute names, or attribute values don't match an existing queue, CreateQueue returns an error.
Read more >MessageAttributeValue - Amazon Simple Queue Service
The user-specified message attribute value. For string data types, the Value attribute has the same restrictions on the content as the message body....
Read more >Unable to send the MessageAttributes to AWS SQS using ...
This should fix your code but right way is to have a look at this import boto3 sqs = boto3.client('sqs') response = sqs.queue.send_message( ......
Read more >Working with Amazon SQS in Python using Boto3
This article covers managing SQS queues, concepts of working with SQS messages, ... In general, here's what you need to have installed:.
Read more >Ultimate Guide to Python SQS: 13+ Operations With Easy ...
You'll learn to create Python SQS Queues using the Boto3 library, set up Queue permissions, attributes, and tags, configure Queue URLs, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Tylermarques - Thank you for providing me the steps to reproduce the issue. Now i am able to reproduce the issue. This is because lambda process the event in different way than the service SQS. I have internally escalated this issue to the service team. I will post here when i get any update.
Hello @swetashre
The example is actually trivial. Put it in a newly created lambda function, add SQS permissions and connect to some SQS feed.
Upon adding the message in the SQS - check the CloudWatch logs. You’ll see the
event
as it is received by lambda - non-capitalized:Note:
stringValue
(and as you’ve seen, Boto3 function “receive_message” would returnStringValue
)messageId
(and Boto3 would returnMessageId
)Records
(and Boto3 would returnMessages
)All of these inconsitencies make it quite problematic to develop code which works with both boto3-responses and the direct responses from AWS.