Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.38.0
Steps to Reproduce
- Create an EventBridge pipe in AWS with any source, and a destination of a lambda function
- Instrument the lambda function with sentry and include the AwsLambdaIntegration
- Observe that when triggered by events from the pipe, sentry errors out while trying to trace the function
The following is the stack trace that is printed out in the logs
AttributeError: 'list' object has no attribute 'items'
Traceback (most recent call last):
File "/var/task/sentry_sdk/integrations/aws_lambda.py", line 145, in sentry_handler
transaction = continue_trace(
File "/var/task/sentry_sdk/api.py", line 269, in continue_trace
return Hub.current.continue_trace(environ_or_headers, op, name, source)
File "/var/task/sentry_sdk/hub.py", line 596, in continue_trace
normalize_incoming_data(environ_or_headers),
File "/var/task/sentry_sdk/tracing_utils.py", line 497, in normalize_incoming_data
for key, value in incoming_data.items():
Expected Result
Sentry is able to trace the function invocation
Actual Result
Sentry crashes and ends execution of the function.
The root of the issue seems to be that the AwsLambdaIntegration
expects that if the headers
key exists in the request, that it will be a dictionary. However when EventBridge triggers the lambda with data, it sends headers as an empty list. Sample payload below.
[
{
"topic": "lps-ranges",
"partition": 1,
"offset": 0,
"timestamp": 1701268939207,
"timestampType": "CREATE_TIME",
"key": "REDACTED",
"value": "REDACTED",
"headers": [],
"eventSourceArn": "REDACTED",
"bootstrapServers": "REDACTED",
"eventSource": "aws:kafka",
"eventSourceKey": "lps-ranges-1"
}
]
This is where the error is caused in the lambda integration. https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/aws_lambda.py#L140-L143
This should probably be inverted to set headers to an empty dict if it is not a dict, instead of checking only if it is None.
Metadata
Metadata
Assignees
Type
Projects
Status