Skip to content

Commit 3b3d981

Browse files
authored
check if event is a dict before getting
1 parent ea0a09e commit 3b3d981

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

datadog_lambda/tracing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ def is_legacy_lambda_step_function(event):
411411
"""
412412
Check if the event is a step function that called a legacy lambda
413413
"""
414+
if not isinstance(event, dict):
415+
return False
416+
414417
event = event.get("Payload", {})
415418
return "Execution" in event and "StateMachine" in event and "State" in event
416419

tests/test_tracing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ def test_is_legacy_lambda_step_function(self):
678678
}
679679
self.assertFalse(is_legacy_lambda_step_function(sf_event))
680680

681+
other_event = ["foo", "bar"]
682+
self.assertFalse(is_legacy_lambda_step_function(other_event))
683+
681684

682685
class TestXRayContextConversion(unittest.TestCase):
683686
def test_convert_xray_trace_id(self):

0 commit comments

Comments
 (0)