Open vayias opened 6 years ago
A PR with that check seems reasonable, haven't played much with step functions myself.
Thanks for the response @kevgliss. Before creating the PR, I'm trying to figure out if anything will end-up braking in the underlying raven
code as a result of this change. Any thoughts around that?
Thats an interesting question, I'm not sure how you would reconcile multiple events in the context of one lambda? i.e. when you are writing your lambda code is it expected that one lambda will process all of the events? Moreover, if any error is encountered should you report for only the event that caused the failure (probably) or report them all?
What you could do is write your lambda as if it expects one event (like a normal non step function), and let the decorator iterate over your events (if they exist) adding the most specific context (event) as it goes.
The only down side to that is the decorator is now part of the processing logic (converting list of dicts to list) which may not be what you want.
Context: Step functions is a technology aws offers to coordinate and manage the execution of your lambdas.
Issue: Lambda function can have as input parameters, an
event
and acontext
.event
is always guaranteed to be adict
.In step-functions you can have multiple lambda functions get executed in parallel. The generated output of this parallel state, is an array with one element for each branch containing the output from that branch. That means that a lambda function that will get called after this parallel state, will have the parameter
event
being of typelist
instead of adict
.So when you try to report to sentry using
raven-python-lambda
in this lambda function thatevent
is not a dict, and so it breaks. It breaks because of the numerousevent.get
calls in the__init__.py
file. Error isAttributeError: 'list' object has no attribute 'get'
I was thinking of creating a PR that simply will check if the type of
event
is adict
before doing attempting theevent.get
.Do you guys think this is acceptable? Any thoughts around that? Will be happy to chat about this more.