Skip to content

Commit 5a54b57

Browse files
authored
🔧 chore: handle when incident open period model isn't written to (#93836)
1 parent 20335e1 commit 5a54b57

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sentry/integrations/metric_alerts.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import NotRequired, TypedDict
55
from urllib import parse
66

7+
import sentry_sdk
78
from django.db.models import Max
89
from django.urls import reverse
910
from django.utils.translation import gettext as _
@@ -229,18 +230,16 @@ def incident_attachment_info(
229230
except AlertRuleDetector.DoesNotExist:
230231
raise ValueError("Alert rule detector not found when querying for AlertRuleDetector")
231232

233+
workflow_engine_params = title_link_params.copy()
234+
232235
try:
233236
open_period_incident = IncidentGroupOpenPeriod.objects.get(
234237
group_open_period_id=metric_issue_context.open_period_identifier
235238
)
236-
except IncidentGroupOpenPeriod.DoesNotExist:
237-
raise ValueError(
238-
"Incident group open period not found when querying for IncidentGroupOpenPeriod"
239-
)
240-
241-
workflow_engine_params = title_link_params.copy()
242-
243-
workflow_engine_params["alert"] = str(open_period_incident.incident_identifier)
239+
workflow_engine_params["alert"] = str(open_period_incident.incident_identifier)
240+
except IncidentGroupOpenPeriod.DoesNotExist as e:
241+
sentry_sdk.capture_exception(e)
242+
# Swallowing the error here since this model isn't being written to just yet
244243

245244
title_link = build_title_link(alert_rule_id, organization, workflow_engine_params)
246245

0 commit comments

Comments
 (0)