File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ def parse_event_source(event: dict) -> _EventSource:
153153 event_source  =  _EventSource (EventTypes .STEPFUNCTIONS )
154154
155155 event_record  =  get_first_record (event )
156-  if  event_record :
156+  if  event_record   and   isinstance ( event_record ,  dict ) :
157157 aws_event_source  =  event_record .get ("eventSource" ) or  event_record .get (
158158 "EventSource" 
159159 )
Original file line number Diff line number Diff line change @@ -280,6 +280,13 @@ def test_detect_lambda_function_url_domain_with_invalid_input(self):
280280 # Test with string that would normally cause an exception when split 
281281 self .assertFalse (detect_lambda_function_url_domain ("" ))
282282
283+  def  test_event_source_with_non_dict_event_record (self ):
284+  # Test with event_record that's not a dictionary 
285+  event  =  {"Records" : "not_a_dict" }
286+  event_source  =  parse_event_source (event )
287+  # Should handle the first non-dict record gracefully and return unknown 
288+  self .assertEqual (event_source .to_string (), "unknown" )
289+ 
283290
284291class  GetTriggerTags (unittest .TestCase ):
285292 def  test_extract_trigger_tags_api_gateway (self ):
                         You can’t perform that action at this time. 
           
                  
0 commit comments