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

Commit 6f41eae

Browse files
Luke Hindsyrobla
andauthored
fix: handle dict type trigger_string in alert deduplication for Cline (#1163)
* 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 * fix lint --------- Co-authored-by: Yolanda Robla <[email protected]>
1 parent eed259d commit 6f41eae

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/codegate/api/v1_processing.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,23 @@ 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+
{
525+
"name": alert.trigger_string.get("name"),
526+
"type": alert.trigger_string.get("type"),
527+
"status": alert.trigger_string.get("status"),
528+
}
529+
)
530+
elif isinstance(alert.trigger_string, str):
531+
# If it's a string, use the part before "Context" if it exists
532+
trigger_string_content = alert.trigger_string.split("Context")[0]
533+
else:
534+
# For any other case, convert to string
535+
trigger_string_content = str(alert.trigger_string)
521536

522537
key = (
523538
alert.code_snippet,

0 commit comments

Comments
 (0)