Skip to content

Fix Discord/NTFY notifications double-posting via generic sender fall-through#754

Open
dny238 wants to merge 1 commit into
Listenarrs:canaryfrom
dny238:bugfix/discord-ntfy-double-post
Open

Fix Discord/NTFY notifications double-posting via generic sender fall-through#754
dny238 wants to merge 1 commit into
Listenarrs:canaryfrom
dny238:bugfix/discord-ntfy-double-post

Conversation

@dny238

@dny238 dny238 commented Jul 12, 2026

Copy link
Copy Markdown

Fixes #753

Problem

The Discord and NTFY handlers in SendNotificationAsync (NotificationService.Webhooks.cs) do not return after handling the notification, so execution falls through to the generic webhook sender and every Discord/NTFY notification is posted a second time.

For Discord, the duplicate is built by CreateDiscordPayload; when the configured base URL is not an absolute http(s) URL (e.g. the default UrlBase of "/"), its embed thumbnail is a relative path, which the Discord API rejects with 400 {"embeds": ["0"]} — so the log shows a delivery failure on every notification even though the first (Discord-specific) send succeeded. When the payload is valid, the channel simply receives two copies.

The Pushover and Telegram handlers already return and are unaffected.

Fix

Add the missing return; at the end of the Discord and NTFY branches, making each service-specific handler terminal for URLs it handles — consistent with the existing Pushover/Telegram behavior.

Tests

Adds NotificationServiceSingleDispatchTests with two regression tests asserting exactly one HTTP request is made per Discord/NTFY notification (using the same mocked-HttpMessageHandler pattern as the existing NotificationServiceTests).

Verified the tests fail before the fix and pass after:

WITHOUT fix: Failed! - Failed: 2, Passed: 0  (two HTTP requests observed per notification)
WITH fix:    Passed! - Failed: 0, Passed: 2

Full notification test group (--filter FullyQualifiedName~NotificationService, 13 tests) passes.

Also verified end-to-end against a live Discord webhook on a dev instance: one message delivered (with cover attachment), no Sending Generic POST follow-up, no 400.

🤖 Generated with Claude Code

…-through

The Discord and NTFY handlers in SendNotificationAsync did not return
after sending, so execution fell through to the generic webhook sender
and every Discord/NTFY notification was posted a second time.

For Discord the duplicate is built by CreateDiscordPayload; when the
configured base URL is not an absolute http(s) URL (e.g. the default
UrlBase "/"), its embed thumbnail is a relative path, which the Discord
API rejects with 400 {"embeds": ["0"]}. The log then shows a delivery
failure even though the first (Discord-specific) send succeeded. When
the embed is valid, the channel simply receives two copies.

Adds regression tests asserting exactly one HTTP request is made per
Discord/NTFY notification (verified failing before the fix).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dny238 dny238 requested a review from a team July 12, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord/NTFY notifications are double-posted; Discord duplicate rejected with 400 {"embeds": ["0"]}

1 participant