Skip to content
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

fix(pagerduty): enforce new format #2552

Merged
merged 1 commit into from
Nov 20, 2024
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
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
Loading