Skip to content

Commit

Permalink
fix(pagerduty): enforce new format (#2552)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Nov 20, 2024
1 parent 57df5a1 commit 917cbc5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions keep/providers/pagerduty_provider/pagerduty_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,9 @@ def _query(self, incident_id: str = None):

@staticmethod
def _format_alert(
event: dict, provider_instance: "BaseProvider" = None
event: dict,
provider_instance: "BaseProvider" = None,
force_new_format: bool = False,
) -> AlertDto:
# If somebody connected the provider before we refactored it
old_format_event = event.get("event", {})
Expand Down Expand Up @@ -622,7 +624,7 @@ def _format_alert_old(event: dict) -> AlertDto:
last_received = data.pop(
"created_at", datetime.datetime.now(tz=datetime.timezone.utc).isoformat()
)
name = data.pop("title")
name = data.pop("title", "unknown title")
service = data.pop("service", {}).get("summary", "unknown")
environment = next(
iter(
Expand Down Expand Up @@ -799,7 +801,8 @@ def _get_incidents(self) -> list[IncidentDto]:
incident_id=incident_dto.fingerprint
)
incident_alerts = [
PagerdutyProvider._format_alert(alert) for alert in incident_alerts
PagerdutyProvider._format_alert(alert, None, force_new_format=True)
for alert in incident_alerts
]
incident_dto._alerts = incident_alerts
incidents.append(incident_dto)
Expand Down

0 comments on commit 917cbc5

Please sign in to comment.