From b96b43007b7a39d36703764310228a164d5579f9 Mon Sep 17 00:00:00 2001 From: Tal Borenstein Date: Tue, 12 Nov 2024 10:28:58 +0200 Subject: [PATCH] fix: more indicative errors when connecting providers --- keep-ui/app/providers/provider-form.tsx | 13 ++++++++++++- .../pagerduty_provider/pagerduty_provider.py | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/keep-ui/app/providers/provider-form.tsx b/keep-ui/app/providers/provider-form.tsx index a9d1956b3..4ffd9c16c 100644 --- a/keep-ui/app/providers/provider-form.tsx +++ b/keep-ui/app/providers/provider-form.tsx @@ -480,7 +480,18 @@ const ProviderForm = ({ }) .catch((error) => { const updatedFormErrors = error.toString(); - setFormErrors(updatedFormErrors); + + if (updatedFormErrors.includes("SyntaxError")) { + setFormErrors( + "Bad response from API: Check the backend logs for more details" + ); + } else if (updatedFormErrors.includes("Failed to fetch")) { + setFormErrors( + "Failed to connect to API: Check your internet connection" + ); + } else { + setFormErrors(updatedFormErrors); + } onFormChange(formValues, updatedFormErrors); setIsLoading(false); onConnectChange(false, false); diff --git a/keep/providers/pagerduty_provider/pagerduty_provider.py b/keep/providers/pagerduty_provider/pagerduty_provider.py index 9aa6e9e88..9a3a5654b 100644 --- a/keep/providers/pagerduty_provider/pagerduty_provider.py +++ b/keep/providers/pagerduty_provider/pagerduty_provider.py @@ -316,7 +316,9 @@ def _format_alert( status = PagerdutyProvider.STATUS_MAP.get(data.pop("status", "firing")) priority_summary = (data.get("priority", {}) or {}).get("summary") priority = PagerdutyProvider.SEVERITIES_MAP.get(priority_summary, "P4") - last_received = data.pop("created_at") + last_received = data.pop( + "created_at", datetime.datetime.now(tz=datetime.timezone.utc).isoformat() + ) name = data.pop("title") service = data.pop("service", {}).get("summary", "unknown") environment = next(