Skip to content

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

Description

@dny238

Describe the bug

Every Discord notification is sent to the webhook twice. The Discord-specific handler in NotificationService.Webhooks.cs sends the notification (multipart with cover attachment, or plain JSON), but does not return afterward — execution falls through to the generic webhook sender at the bottom of SendNotificationAsync, which posts a second copy of the same notification.

Depending on configuration, this shows up two different ways:

  1. Duplicate messages — when the generic payload is valid, the Discord channel receives the same notification twice.
  2. Spurious 400 errors in the log — when the configured base URL is not an absolute http(s) URL (e.g. the default UrlBase of "/" in config.json), the generic payload's embed thumbnail is a relative path (/api/v1/images/<asin>), which the Discord API rejects:
[INF] Sending Generic POST to https://discord.com/api/webhooks/... with body: {"content":"Dracula by Bram Stoker has been added", ... "thumbnail":{"url":"/api/v1/images/B0078PA1OA"} ...}
[WRN] Failed to send notification to https://discord.com/api/webhooks/...: BadRequest - {"embeds": ["0"]}

The log makes delivery look broken even though the first (Discord-specific) send already succeeded — this cost me a while when setting up Discord notifications, since I saw a 400 on every book-added event.

The NTFY handler has the same fall-through, so NTFY targets also receive the notification twice (once as a proper NTFY message with Title/Priority/Tags headers, once as generic JSON).

The Pushover and Telegram handlers already return after handling, so they are unaffected.

To Reproduce

  1. Configure a Discord webhook URL as the notification target (default UrlBase of "/").
  2. Trigger any notification with an image, e.g. add a book to the library (book-added).
  3. Observe the log: the Discord-specific send succeeds (message appears in the channel with cover attachment), followed by a Sending Generic POST to the same webhook that fails with BadRequest - {"embeds": ["0"]}.

Expected behavior

One notification per event per target: the service-specific handler should be terminal for URLs it handles, with no second post through the generic sender.

Environment

  • Version: 1.2.2 (canary)
  • OS: Windows 11 (dev build from source), also applies to current canary sources

Additional context

I have a fix ready (two return statements plus regression tests asserting exactly one HTTP request per Discord/NTFY notification, verified failing before the fix) — PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions