Title: AwsLambdaIntegration crashes when lambda is triggered by EventBridge Pipe source · Issue #2545 · getsentry/sentry-python · GitHub
Open Graph Title: AwsLambdaIntegration crashes when lambda is triggered by EventBridge Pipe source · Issue #2545 · getsentry/sentry-python
X Title: AwsLambdaIntegration crashes when lambda is triggered by EventBridge Pipe source · Issue #2545 · getsentry/sentry-python
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 AwsLamb...
Open Graph 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 func...
X 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 func...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/2545
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AwsLambdaIntegration crashes when lambda is triggered by EventBridge Pipe source ","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n1.38.0\n\n### Steps to Reproduce\n\n1. Create an EventBridge pipe in AWS with any source, and a destination of a lambda function\r\n2. Instrument the lambda function with sentry and include the AwsLambdaIntegration\r\n3. Observe that when triggered by events from the pipe, sentry errors out while trying to trace the function\r\n\r\nThe following is the stack trace that is printed out in the logs\r\n\r\n```\r\nAttributeError: 'list' object has no attribute 'items'\r\nTraceback (most recent call last):\r\n File \"/var/task/sentry_sdk/integrations/aws_lambda.py\", line 145, in sentry_handler\r\n transaction = continue_trace(\r\n File \"/var/task/sentry_sdk/api.py\", line 269, in continue_trace\r\n return Hub.current.continue_trace(environ_or_headers, op, name, source)\r\n File \"/var/task/sentry_sdk/hub.py\", line 596, in continue_trace\r\n normalize_incoming_data(environ_or_headers),\r\n File \"/var/task/sentry_sdk/tracing_utils.py\", line 497, in normalize_incoming_data\r\n for key, value in incoming_data.items():\r\n```\n\n### Expected Result\n\nSentry is able to trace the function invocation\n\n### Actual Result\n\nSentry crashes and ends execution of the function.\r\n\r\nThe 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.\r\n\r\n```json\r\n[\r\n{\r\n \"topic\": \"lps-ranges\",\r\n \"partition\": 1,\r\n \"offset\": 0,\r\n \"timestamp\": 1701268939207,\r\n \"timestampType\": \"CREATE_TIME\",\r\n \"key\": \"REDACTED\",\r\n \"value\": \"REDACTED\",\r\n \"headers\": [],\r\n \"eventSourceArn\": \"REDACTED\",\r\n \"bootstrapServers\": \"REDACTED\",\r\n \"eventSource\": \"aws:kafka\",\r\n \"eventSourceKey\": \"lps-ranges-1\"\r\n}\r\n]\r\n```\r\n\r\nThis 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\r\n\r\nThis 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.","author":{"url":"https://github.com/davidcroda","@type":"Person","name":"davidcroda"},"datePublished":"2023-11-29T16:02:44Z","url":"https://github.com/getsentry/sentry-python/issues/2545"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:23710cff-ddae-ccf8-60b5-c8084dc38968 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E86C:5885B:85FF5:B72E6:6B007F69 |
| html-safe-nonce | 1ec96b71fa5a354dc83b27a508bc601ed1b62fe7d07ee8e9a641434c606d346e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODZDOjU4ODVCOjg1RkY1OkI3MkU2OjZCMDA3RjY5IiwidmlzaXRvcl9pZCI6Ijc3NDAwNDM1MzYwOTUwMTg4NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b2650655f26bfbc52b24b74eab4567470b6c7ae0a0b76ac0bc3064ab00f28bed |
| hovercard-subject-tag | issue:2016920091 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/2545/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9969c616ce2ac68d1534def0083c865d1766594145fe5779aff5d0c67afd2530/getsentry/sentry-python/issues/2545 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9969c616ce2ac68d1534def0083c865d1766594145fe5779aff5d0c67afd2530/getsentry/sentry-python/issues/2545 |
| og:image:alt | 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 func... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | davidcroda |
| hostname | github.com |
| expected-hostname | github.com |
| None | 82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1bc2aa1939001689f5ce935982c10a6138f745c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width