@@ -94,7 +94,20 @@ async def list_repo_incidents(
9494 "incidents" : incidents_result ,
9595 "total_count" : len (incidents_result ),
9696 }
97- return incidents_result
97+ elif isinstance (incidents_result , dict ):
98+ return {
99+ "source_id" : source_id ,
100+ "incidents" : incidents_result .get ("data" , []),
101+ "total_count" : incidents_result .get ("total_count" , len (incidents_result .get ("data" , []))),
102+ }
103+ else :
104+ # Fallback for unexpected types
105+ return {
106+ "source_id" : source_id ,
107+ "incidents" : [],
108+ "total_count" : 0 ,
109+ "error" : f"Unexpected response type: { type (incidents_result ).__name__ } " ,
110+ }
98111 else :
99112 incidents_result = await client .list_source_incidents (source_id , ** params )
100113 if isinstance (incidents_result , dict ):
@@ -104,7 +117,21 @@ async def list_repo_incidents(
104117 "next_cursor" : incidents_result .get ("next_cursor" ),
105118 "total_count" : incidents_result .get ("total_count" , 0 ),
106119 }
107- return incidents_result
120+ elif isinstance (incidents_result , list ):
121+ # Handle case where API returns a list directly
122+ return {
123+ "source_id" : source_id ,
124+ "incidents" : incidents_result ,
125+ "total_count" : len (incidents_result ),
126+ }
127+ else :
128+ # Fallback for unexpected types
129+ return {
130+ "source_id" : source_id ,
131+ "incidents" : [],
132+ "total_count" : 0 ,
133+ "error" : f"Unexpected response type: { type (incidents_result ).__name__ } " ,
134+ }
108135 else :
109136 # Use repository_name lookup (legacy path)
110137 result = await client .list_repo_incidents_directly (
0 commit comments