diff --git a/src/codegate/api/v1_processing.py b/src/codegate/api/v1_processing.py index cb2c0c9b..10f42075 100644 --- a/src/codegate/api/v1_processing.py +++ b/src/codegate/api/v1_processing.py @@ -516,8 +516,23 @@ async def remove_duplicate_alerts(alerts: List[v1_models.Alert]) -> List[v1_mode alerts, key=lambda x: x.timestamp, reverse=True ): # Sort alerts by timestamp descending - # Extract trigger string content until "Context" - trigger_string_content = alert.trigger_string.split("Context")[0] + # Handle trigger_string based on its type + trigger_string_content = "" + if isinstance(alert.trigger_string, dict): + # If it's a dict, use relevant fields for deduplication + trigger_string_content = json.dumps( + { + "name": alert.trigger_string.get("name"), + "type": alert.trigger_string.get("type"), + "status": alert.trigger_string.get("status"), + } + ) + elif isinstance(alert.trigger_string, str): + # If it's a string, use the part before "Context" if it exists + trigger_string_content = alert.trigger_string.split("Context")[0] + else: + # For any other case, convert to string + trigger_string_content = str(alert.trigger_string) key = ( alert.code_snippet,