question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v0.18.0+ regression with batched lambda events

See original GitHub issue

This line got introduced in v0.18.0 that assumes that the event object will always be a dict, but there are cases where the lambda event object can be a List[dict].

BatchInvoke events with AppSync [1] are the ones that I’m running up against right now after trying to upgrade the sdk. Anytime I invoke the lambda with a resolver configured with BatchInvoke, the lambda function fails right away (and without a sentry error, which is understandable…but made finding this a real pain)

[ERROR] AttributeError: 'list' object has no attribute 'get'
Traceback (most recent call last):
  File "/var/task/sentry_sdk/integrations/aws_lambda.py", line 106, in sentry_handler
    headers = event.get("headers", 
{}
)

[1] https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-lambda.html#request-mapping-template

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
untitakercommented, Nov 4, 2020

We are working on a fix.

0reactions
lobsterkatiecommented, Nov 9, 2020

Great, thanks!

And yup - have seen that page, but wasn’t sure if multiple entries inside of event meant there might be multiple context objects. But the two “contexts” being unrelated makes more sense now, as the one in your mapping template calls upon properties not listed on that spec page for the passed context object. Them being independent also explains how in your mapping template, there seemed to be one $context per record, whereas you’ve just confirmed that there’s only one passed context object per batch request.

About to push a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to add an SQS event source to a Lambda function with ...
I'm unable to connect Lambda function to an SQS event source. ... It seems that this might be a regression bug introduced in...
Read more >
AWS Lambda now supports partial batch response for SQS as ...
AWS Lambda now supports partial batch response for SQS as an event source. With this feature, when messages on an SQS queue fail...
Read more >
LambdaSharp "Hicetas" Release (v0.8.3.4) - 2021-07-15
The ALambdaFunction base class has new methods for sending events, capturing metrics, and logging debug statements. In addition, the LambdaSharp.
Read more >
@aws-cdk/aws-lambda-event-sources - Package Manager
An event source mapping is an AWS Lambda resource that reads from an event source and invokes a Lambda function. You can use...
Read more >
Batch Processing - AWS Lambda Powertools for Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found