Log errors returned when sending webhook alerts#1182
Merged
msafwankarim merged 1 commit intoJul 10, 2026
Merged
Conversation
The alert send functions (Slack/Teams/GChat/raw) return `[]error`, but `SendWebhookAlert` discarded them, so a failing webhook — e.g. a Teams alert returning a non-2xx status — produced no output at all, even at trace level (stakater#949). Capture the returned errors and log each with `logrus.Errorf`, as suggested by the maintainer on the issue. Adds a regression test that drives a failing (500) webhook and asserts the error is logged. Closes stakater#949 Assisted-by: Claude Code (Anthropic, Opus 4.x)
msafwankarim
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #949.
Problem
With
ALERT_ON_RELOAD=trueand a webhook sink (e.g.ALERT_SINK=teams), a failing webhook produced no output at all — not even atlogLevel: trace. The alert simply didn't arrive and there was nothing to debug.Cause
SendWebhookAlertcallssendSlackAlert/sendTeamsAlert/sendGoogleChatAlert/sendRawWebhookAlert, each of which returns[]error, but the return values were discarded. A non-2xx response (or a transport error) was therefore silently swallowed.Fix
Capture the returned errors and log each with
logrus.Errorf("Error sending alert: %s", ...)— exactly as @Felix-Stakater suggested on the issue. A misconfigured or failing webhook now surfaces a clear error log:Tests
Added
TestSendWebhookAlert_LogsSendErrors(internal/pkg/alerts/alert_test.go): stands up anhttptestserver that returns500, points a Teams sink at it, and asserts the error is logged (via alogrustest hook). It fails without this change and passes with it.go build ./...,gofmt, and the new test are green.Developed with AI assistance (Claude Code); I directed the change and verified build/test locally.