We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When processing Amazon SNS events using an AWS Lambda function customers can use a built-in envelope to quickly access the contents of the message.
The envelope should be able to process both messages that are plain strings or JSON encoded strings.
Currently if the Message field is a plain text string, the envelope will throw an error because it always attempts to JSON.parse() it.
Message
JSON.parse()
For example, this fails:
{ "Records": [ { "EventVersion": "1.0", "EventSubscriptionArn": "arn:aws:sns:us-east-2:123456789012:sns-la ...", "EventSource": "aws:sns", "Sns": { "SignatureVersion": "1", "Timestamp": "2019-01-02T12:45:07.000Z", "Signature": "tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==", "SigningCertUrl": "https://sns.us-east-2.amazonaws.com/SimpleNotification", "MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", "Message": "Hello from SNS!", "MessageAttributes": { "Test": { "Type": "String", "Value": "TestString" }, "TestBinary": { "Type": "Binary", "Value": "TestBinary" } }, "Type": "Notification", "UnsubscribeUrl": "https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe", "TopicArn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", "Subject": "TestInvoke" } } ] }
const parsedBody = SnsEnvelope.parse(event, testSchema);
N/A
No response
latest
20.x
npm
Failed to parse envelope. This error was caused by: Unexpected token 'H', "Hello from SNS!" is not valid JSON.
The text was updated successfully, but these errors were encountered:
When fixing this, change the it.fails() test to it() in packages/parser/tests/unit/envelopes/sns.test.ts which was introduced in #3248.
it.fails()
it()
packages/parser/tests/unit/envelopes/sns.test.ts
Sorry, something went wrong.
No branches or pull requests
Expected Behavior
When processing Amazon SNS events using an AWS Lambda function customers can use a built-in envelope to quickly access the contents of the message.
The envelope should be able to process both messages that are plain strings or JSON encoded strings.
Current Behavior
Currently if the
Message
field is a plain text string, the envelope will throw an error because it always attempts toJSON.parse()
it.For example, this fails:
Code snippet
Steps to Reproduce
N/A
Possible Solution
No response
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
Failed to parse envelope. This error was caused by: Unexpected token 'H', "Hello from SNS!" is not valid JSON.
The text was updated successfully, but these errors were encountered: