workers-builds-notifications-template: Fix empty Discord webhook messages#956
workers-builds-notifications-template: Fix empty Discord webhook messages#956JoshuaKirby88 wants to merge 1 commit intocloudflare:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Discord webhook integration by adding a top-level text field to Slack-formatted payloads, preventing the "Cannot send an empty message" error from Discord's Slack-compatible webhook endpoint. The changes ensure all webhook messages include a fallback text field, which is required by Discord but optional for Slack.
Changes:
- Added
textfield toSlackPayloadinterface and all message builder functions with descriptive values including emojis - Enhanced error logging in
sendSlackNotificationto include the sent payload for easier debugging - Clarified README documentation to specify that queue subscriptions are per-worker, not for all workers in the account
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| workers-builds-notifications-template/src/slack.ts | Added optional text field to SlackPayload interface; updated all message builders to return descriptive text values; ensured fallback text in sendSlackNotification; improved error logging |
| workers-builds-notifications-template/README.md | Clarified that --worker-name in subscriptions refers to the source worker being built, not the consumer worker; updated architecture diagram and test instructions to reflect per-worker subscription scope |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const body = JSON.stringify({ | ||
| ...payload, | ||
| text: payload.text || "Workers Build Notification", | ||
| }); |
There was a problem hiding this comment.
The new top-level text field added to fix Discord webhook compatibility is not covered by tests. Consider adding test assertions to verify that the text field is present in the payload sent to the webhook and contains the expected values for different event types (success, failure, cancelled, fallback).
Summary
Fixes webhook payload formatting so Discord Slack-compatible webhooks don’t reject messages with:
400 {"message":"Cannot send an empty message","code":50006}Changes
textto Slack payload type and message builders.sendSlackNotificationalways sends a fallbacktext("Workers Build Notification"), even when only blocks arepresent.