From 8febd23f48a85a1bc388dd94803dce0a31b3dfd6 Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Sat, 23 Aug 2025 07:33:14 +0000 Subject: [PATCH] fix: properly report HTTP errors in webhook tests - Webhook test was showing success even when receiving 400/500 errors - Now correctly reports HTTP status errors to the UI - Added debug logging for Gotify webhooks to help troubleshooting - Addresses #342 where Gotify webhooks appeared to work but didn't --- internal/api/notifications.go | 5 +++++ internal/notifications/notifications.go | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/api/notifications.go b/internal/api/notifications.go index 5cff3894d..83c6b3e08 100644 --- a/internal/api/notifications.go +++ b/internal/api/notifications.go @@ -427,6 +427,11 @@ func (h *NotificationHandlers) TestWebhook(w http.ResponseWriter, r *http.Reques if err != nil { result["error"] = err.Error() w.WriteHeader(http.StatusBadRequest) + } else if status < 200 || status >= 300 { + // HTTP error from webhook endpoint + result["error"] = fmt.Sprintf("Webhook returned HTTP %d: %s", status, response) + result["success"] = false + w.WriteHeader(http.StatusBadRequest) } else { result["success"] = true } diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go index f459b3c0a..4b1047533 100644 --- a/internal/notifications/notifications.go +++ b/internal/notifications/notifications.go @@ -622,13 +622,14 @@ func (n *NotificationManager) sendWebhookRequest(webhook WebhookConfig, jsonData req.Header.Set(key, value) } - // Debug log the payload for Telegram webhooks - if webhook.Service == "telegram" { + // Debug log the payload for Telegram and Gotify webhooks + if webhook.Service == "telegram" || webhook.Service == "gotify" { log.Debug(). Str("webhook", webhook.Name). + Str("service", webhook.Service). Str("url", webhookURL). Str("payload", string(jsonData)). - Msg("Sending Telegram webhook") + Msg("Sending webhook with payload") } // Send request