Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datadog_lambda/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def parse_event_source(event: dict) -> _EventSource:
event_source = _EventSource(EventTypes.STEPFUNCTIONS)

event_record = get_first_record(event)
if event_record:
if event_record and isinstance(event_record, dict):
aws_event_source = event_record.get("eventSource") or event_record.get(
"EventSource"
)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ def test_detect_lambda_function_url_domain_with_invalid_input(self):
# Test with string that would normally cause an exception when split
self.assertFalse(detect_lambda_function_url_domain(""))

def test_event_source_with_non_dict_event_record(self):
# Test with event_record that's not a dictionary
event = {"Records": "not_a_dict"}
event_source = parse_event_source(event)
# Should handle the first non-dict record gracefully and return unknown
self.assertEqual(event_source.to_string(), "unknown")


class GetTriggerTags(unittest.TestCase):
def test_extract_trigger_tags_api_gateway(self):
Expand Down
Loading