Fix Discord/NTFY notifications double-posting via generic sender fall-through#754
Open
dny238 wants to merge 1 commit into
Open
Fix Discord/NTFY notifications double-posting via generic sender fall-through#754dny238 wants to merge 1 commit into
dny238 wants to merge 1 commit into
Conversation
…-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>
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.
Fixes #753
Problem
The Discord and NTFY handlers in
SendNotificationAsync(NotificationService.Webhooks.cs) do notreturnafter 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 absolutehttp(s)URL (e.g. the defaultUrlBaseof"/"), its embed thumbnail is a relative path, which the Discord API rejects with400 {"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
returnand 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
NotificationServiceSingleDispatchTestswith two regression tests asserting exactly one HTTP request is made per Discord/NTFY notification (using the same mocked-HttpMessageHandlerpattern as the existingNotificationServiceTests).Verified the tests fail before the fix and pass after:
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 POSTfollow-up, no 400.🤖 Generated with Claude Code