fix(parser): SNS Envelope handles non-JSON #3506
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Changes
This PR updates the
SNSEnvelope
built-in envelope so that it's able to handle non JSON-stringified payloads in theMessage
field.Before this PR the envelope would always assume messages are JSON-stringified objects and attempt to transform them after having parsed them. This prevented customers from working with payloads that are simple strings, i.e.
The new implementation of the envelope moves the parsing in its own implementation and removes the usage of the
Envelope
abstraction, as well as leaving the choice of adding a transform to customers using it, i.e.Additionally, similar to what done in other recent PRs I have also improved the error messaging so that it includes the full path of the error and also made it so the
Records
array must contain at least one item. Below an example of the new error:The PR also moves out of the SNS envelope the
SnsSqsEnvelope
, which despite the name, is actually a SQS envelope that wraps SNS messages. For this reason I had to also move the unit tests. A more thorough refactor will come in a future PR when I work on the SQS envelopes.Issue number: fixes #3266
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.