Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 47fb5f1

Browse files
author
Luke Hinds
committed
fix: handle dict type trigger_string in alert deduplication for Cline
The alert deduplication logic was failing when trigger_string was a dictionary, causing an AttributeError when trying to call split() on it. Updated the code to: - Check trigger_string type before processing - Handle dictionary case by creating a consistent JSON string from relevant fields - Maintain existing string handling for backwards compatibility - Add fallback for other types by converting to string This ensures alerts are properly deduplicated regardless of trigger_string format. Fixes: #1162
1 parent 8b2993b commit 47fb5f1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/codegate/api/v1_processing.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,21 @@ async def remove_duplicate_alerts(alerts: List[v1_models.Alert]) -> List[v1_mode
516516
alerts, key=lambda x: x.timestamp, reverse=True
517517
): # Sort alerts by timestamp descending
518518

519-
# Extract trigger string content until "Context"
520-
trigger_string_content = alert.trigger_string.split("Context")[0]
519+
# Handle trigger_string based on its type
520+
trigger_string_content = ""
521+
if isinstance(alert.trigger_string, dict):
522+
# If it's a dict, use relevant fields for deduplication
523+
trigger_string_content = json.dumps({
524+
'name': alert.trigger_string.get('name'),
525+
'type': alert.trigger_string.get('type'),
526+
'status': alert.trigger_string.get('status')
527+
})
528+
elif isinstance(alert.trigger_string, str):
529+
# If it's a string, use the part before "Context" if it exists
530+
trigger_string_content = alert.trigger_string.split("Context")[0]
531+
else:
532+
# For any other case, convert to string
533+
trigger_string_content = str(alert.trigger_string)
521534

522535
key = (
523536
alert.code_snippet,

0 commit comments

Comments
 (0)