-
Notifications
You must be signed in to change notification settings - Fork 153
fix(parser): Kafka Envelope + tests #3489
New issue
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
Conversation
…ls-lambda-typescript into fix/kafka_parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment on the bootstrapServers
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
|
Summary
Changes
This PR updates the Kafka Envelope schema and logic by making sure that the result is a list of values rather than a list that contains a list of values, i.e. the result went from this
[['{"key":"value"}']]
to this['{"key":"value"}']
.The linked issue contains an explanation of why the result was the way it was and also why that is a bug, but essentially a Lambda function can subscribe to a single topic/partition and thus there's no need to accommodate multiple lists of values since all values will inevitably belong to the same topic/partition combination.
While working on the PR, I also removed from the envelope the forced JSON transform of the values which was causing the envelope to not work with values that were anything other than a JSON-stringified string.
For example, the following payload, which has
aGVsbG8=
(aka"hello world"
) as value would not have worked because the envelope was always trying to runJSON.parse()
on the decoded value:The new logic will stop at the base64 decoding and not make assumptions on the actual contents of the string. Customers can still use the
JSONStringified
we provide to do the parse and transform if they know it's of an appropriate type. For example, they can parse this event where value is"eyJrZXkiOiJ2YWx1ZSJ9"
(aka"{\"key\":\"value\"}"
):like this:
KafkaEnvelope.parse(event, JSONStringified(z.object({ key: z.string() })))
(which will work also when using the Middy.js middleware or decorator.Issue number: fixes #3488
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.