notify: a reply other than 2xx is a failed delivery #295

Merged
clawbot merged 1 commits from issue-287-redirect-is-failure into next 2026-10-15 16:14:20 +02:00
Collaborator

Fixes #287.

A notification endpoint that answered with a redirect was counted as delivered. Only a status of 400 or more counted as a failure, and the request is sent straight through the transport rather than an HTTP client, so a 301, 302 or 307 is never followed. The delivery was not retried or logged, and the notification never arrived.

sendNtfy and sendSlack (which also sends to Mattermost) now treat any status outside 200-299 as a failed delivery. It is retried and logged like a network error or a 5xx. The constant that named 400 is gone; the check uses the standard library's status names.

New test: a local test server answers 302 to ntfy, Slack and Mattermost. It must receive each endpoint's first attempt and its retry, and each endpoint must log its retry line and then failed to send notification after retries, with the 302 in the error. That log check was already written out in the connection-refused test, so it now lives in one helper that both tests call.

README, Notifications, now says a delivery fails on "an HTTP status other than 2xx". The sendSlack doc comment was the only other place that said which statuses fail; it is updated to match.

Judgement call: the redirect is still not followed. Following a 301 or 302 would turn the POST into a GET and drop the notification body.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/dnswatcher/issues/287. A notification endpoint that answered with a redirect was counted as delivered. Only a status of 400 or more counted as a failure, and the request is sent straight through the transport rather than an HTTP client, so a `301`, `302` or `307` is never followed. The delivery was not retried or logged, and the notification never arrived. `sendNtfy` and `sendSlack` (which also sends to Mattermost) now treat any status outside 200-299 as a failed delivery. It is retried and logged like a network error or a `5xx`. The constant that named 400 is gone; the check uses the standard library's status names. New test: a local test server answers `302` to ntfy, Slack and Mattermost. It must receive each endpoint's first attempt and its retry, and each endpoint must log its retry line and then `failed to send notification after retries`, with the 302 in the error. That log check was already written out in the connection-refused test, so it now lives in one helper that both tests call. README, Notifications, now says a delivery fails on "an HTTP status other than 2xx". The `sendSlack` doc comment was the only other place that said which statuses fail; it is updated to match. Judgement call: the redirect is still not followed. Following a `301` or `302` would turn the POST into a GET and drop the notification body. Model: opus-5-5
clawbot added the needs-review label 2026-10-15 14:58:18 +02:00
clawbot self-assigned this 2026-10-15 14:58:19 +02:00
Author
Collaborator

Passes review; needs a rebase onto next for TODO.md alone.

Model: opus-5-5

Passes review; needs a rebase onto `next` for `TODO.md` alone. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-15 15:57:01 +02:00
clawbot added 1 commit 2026-10-15 16:04:40 +02:00
A notification endpoint that answered with a redirect was counted as
delivered: the request is not sent through a client, so the redirect
is never followed, and only a status of 400 or more counted as a
failure. Now any status outside 200-299 fails the delivery for ntfy,
Slack and Mattermost, so it is retried and logged like the others.

Model: opus-5-5
clawbot force-pushed issue-287-redirect-is-failure from a1caf4914c to fafb53da35 2026-10-15 16:04:40 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-10-15 16:04:42 +02:00
clawbot merged commit caa3aa3c12 into next 2026-10-15 16:14:20 +02:00
clawbot deleted branch issue-287-redirect-is-failure 2026-10-15 16:14:20 +02:00
Sign in to join this conversation.