Skip to content
Merged
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
9 changes: 9 additions & 0 deletions deliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ func deliverSuccessNotification(url string) error {
}
defer resp.Body.Close()
if resp.StatusCode > 299 || resp.StatusCode < 200 {
// special case: don't send failures for intermittent Uptime Kuma bug
// https://github.com/louislam/uptime-kuma/issues/5357 :
if resp.StatusCode == 404 {
body, _ := io.ReadAll(resp.Body)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Check the error from io.ReadAll.

Ignoring the error from io.ReadAll could mask I/O failures and lead to incorrect behavior. If reading the body fails, the workaround condition won't be evaluated correctly.

Apply this diff to handle the error:

-		body, _ := io.ReadAll(resp.Body)
+		body, err := io.ReadAll(resp.Body)
+		if err != nil {
+			return fmt.Errorf("failed to GET '%s' (%s, could not read response body: %w)", url, resp.Status, err)
+		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
body, _ := io.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("failed to GET '%s' (%s, could not read response body: %w)", url, resp.Status, err)
}
🤖 Prompt for AI Agents
In deliver.go around line 264, the io.ReadAll call ignores its error; change it
to capture the error (body, err := io.ReadAll(resp.Body)) and handle err: close
resp.Body if needed, log or wrap and return the error (or propagate it up) so
failures reading the response body don’t get silently ignored and the subsequent
workaround condition is evaluated against a valid body.

if strings.Contains(string(body), "ok\":false") && strings.Contains(string(body), "Duplicate entry") {
return nil
}
}

return fmt.Errorf("failed to GET '%s' (%s)", url, resp.Status)
}
return nil
Expand Down