Skip to content

Commit 3eb3590

Browse files
authored
Guard against non-dict Payload in is_step_function_event (#846)
Some Step Functions integrations pass a string Payload, which previously caused incorrect behavior when checking for step function event fields.
1 parent e98d951 commit 3eb3590

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

datadog_lambda/trigger.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ def is_step_function_event(event):
461461
The actual event must contain "Execution", "StateMachine", and "State" fields.
462462
"""
463463
event = event.get("Payload", event)
464+
if not isinstance(event, dict):
465+
return False
464466

465467
# JSONPath style
466468
if "Execution" in event and "StateMachine" in event and "State" in event:

tests/test_trigger.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,7 @@ def test_is_step_function_event_dd_header(self):
757757
}
758758
}
759759
self.assertFalse(is_step_function_event(event))
760+
761+
def test_is_step_function_event_payload_not_dict(self):
762+
event = {"Payload": "This is a string, not a dict"}
763+
self.assertFalse(is_step_function_event(event))

0 commit comments

Comments
 (0)