GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(aws): Don't crash if `event` isn't a single dict by lobsterkatie · Pull Request #915 · getsentry/sentry-python

Conversation

@lobsterkatie

@lobsterkatie lobsterkatie commented Nov 9, 2020

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lobsterkatie added 2 commits November 9, 2020 09:48
@lobsterkatie
disambiguate events and contexts (aws vs sentry)
d06d91d
@lobsterkatie
fix bug
a406aa6
@lobsterkatie
lobsterkatie force-pushed the kmclb-fix-batch-events-aws branch from 75ba258 to a406aa6 Compare November 10, 2020 01:40
@lobsterkatie
lobsterkatie requested a review from untitaker November 10, 2020 05:23
untitaker
untitaker reviewed Nov 10, 2020
View reviewed changes
Comment thread tests/integrations/aws_lambda/test_aws.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

untitaker
untitaker approved these changes Nov 10, 2020
View reviewed changes
@lobsterkatie
remove some test options to speed up tests
9798528
@lobsterkatie
lobsterkatie merged commit 0661bce into master Nov 10, 2020
@lobsterkatie
lobsterkatie deleted the kmclb-fix-batch-events-aws branch November 10, 2020 20:58
@sentry-junior sentry-junior Bot mentioned this pull request Nov 12, 2026
fix(aws-lambda): Remove messaging.batch.message_count from the Lambda span #8229
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@untitaker untitaker untitaker approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

v0.18.0+ regression with batched lambda events

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lobsterkatie @untitaker
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.