Skip to content

fix(aws): Don't crash if event isn't a single dict - #915

Merged
lobsterkatie merged 3 commits into
masterfrom
kmclb-fix-batch-events-aws
Nov 10, 2020
Merged

lobsterkatie merged 3 commits into
masterfrom
kmclb-fix-batch-events-aws

Conversation

@lobsterkatie

Copy link
Copy Markdown
Member

Per https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html, the event argument passed to the lambda function handler can be any jsonifiable type - string, int, list, etc - rather than just the dictionary we've previously assumed it to be. (This is particularly relevant for batch requests, which come in as a list of event dictionaries.)

When faced with such an event, our current integration crashes, because it tries to run .get() on it. This fixes that, by introducing the following behavior:

  • If event is a list, tag the transaction as a batch and with the batch size.
  • If event is a list, take the first entry as representative for the purposes of grabbing request data.
  • If event (or the representative) isn't a dictionary, handle it gracefully and move on without request data.

Fixes #891.

@lobsterkatie
lobsterkatie force-pushed the kmclb-fix-batch-events-aws branch from 75ba258 to a406aa6 Compare November 10, 2020 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.18.0+ regression with batched lambda events

2 participants