Skip to content

Commit

Permalink
fix: more indicative errors when connecting providers
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Nov 12, 2024
1 parent 3aaa8c6 commit b96b430
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion keep-ui/app/providers/provider-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion keep/providers/pagerduty_provider/pagerduty_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b96b430

Please sign in to comment.