From 1b94cbdb8a5de0a2f9b4b39f1d2c7132fe59fc9c Mon Sep 17 00:00:00 2001 From: peter <1674920+peterbitfly@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:19:10 +0000 Subject: [PATCH] chore(v1): demote webhook errors to warnings --- services/notifications.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/notifications.go b/services/notifications.go index 638075d1fd..741bd53f56 100644 --- a/services/notifications.go +++ b/services/notifications.go @@ -998,7 +998,7 @@ func sendWebhookNotifications(useDB *sqlx.DB) error { } resp, err := client.Post(n.Content.Webhook.Url, "application/json", reqBody) if err != nil { - logger.WithError(err).Errorf("error sending request") + logger.WithError(err).Warnf("error sending request") } else { metrics.NotificationsSent.WithLabelValues("webhook", resp.Status).Inc() } @@ -1021,11 +1021,11 @@ func sendWebhookNotifications(useDB *sqlx.DB) error { if resp != nil { b, err := io.ReadAll(resp.Body) if err != nil { - logger.WithError(err).Error("error reading body") + logger.WithError(err).Warn("error reading body") + } else { + errResp.Status = resp.Status + errResp.Body = string(b) } - - errResp.Status = resp.Status - errResp.Body = string(b) } _, err = useDB.Exec(`UPDATE users_webhooks SET retries = retries + 1, last_sent = now(), request = $2, response = $3 WHERE id = $1;`, n.Content.Webhook.ID, n.Content, errResp) @@ -1140,7 +1140,7 @@ func sendDiscordNotifications(useDB *sqlx.DB) error { if strings.Contains(errResp.Body, "You are being rate limited") { logger.Warnf("could not push to discord webhook due to rate limit. %v url: %v", errResp.Body, webhook.Url) } else { - utils.LogError(nil, "error pushing discord webhook", 0, map[string]interface{}{"errResp.Body": errResp.Body, "webhook.Url": webhook.Url}) + utils.LogWarn(nil, "error pushing discord webhook", 0, map[string]interface{}{"errResp.Body": errResp.Body, "webhook.Url": webhook.Url}) } _, err = useDB.Exec(`UPDATE users_webhooks SET request = $2, response = $3 WHERE id = $1;`, webhook.ID, reqs[i].Content.DiscordRequest, errResp) if err != nil {