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: more indicative errors when connecting providers #2443

Merged
Show file tree
Hide file tree
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
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some providers have the API host setting and it could be the problem.

Suggested change
"Failed to connect to API: Check your internet connection"
"Failed to connect to API: Check provider settings and 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
Loading