Skip to content

fix: handle dict type trigger_string in alert deduplication for Cline #1163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/codegate/api/v1_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down