fix(Discord): Move message content to embed description field#529
fix(Discord): Move message content to embed description field#529chernistry wants to merge 2 commits intografana:mainfrom
Conversation
The Discord notifier was placing the alert message in the webhook's top-level content field, which renders above the embed. This caused the message text to appear above the title instead of below it. Move the message to the embed's description field so it renders below the title within the embed, matching the behavior of other notification channels like Slack. Also increases the truncation limit from 2000 (content limit) to 4096 (embed description limit) per Discord API documentation. Fixes grafana/grafana#86565
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit c50833f. Configure here.
| tmplErr = nil | ||
| } | ||
| truncatedMsg, truncated := receivers.TruncateInRunes(msg.Content, discordMaxMessageLen) | ||
| messageText, truncated := receivers.TruncateInRunes(messageText, discordMaxDescriptionLen) |
There was a problem hiding this comment.
Embed total may exceed Discord's 6000 character limit
Medium Severity
Moving the message from the top-level content field (which doesn't count toward embed limits) into the embed Description field (which does) means the message text now contributes to Discord's 6000-character total across all embeds. With discordMaxDescriptionLen at 4096, plus discordMaxTitleLen at 256, footer text, and up to 9 image embed titles (each up to 256 chars), the theoretical maximum is ~6681 characters — exceeding 6000. Discord will reject such messages. Previously, the content field was outside embeds so this limit couldn't be hit.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c50833f. Configure here.
- Remove dead constant discordMaxMessageLen (no longer referenced after truncation switched to discordMaxDescriptionLen) - Add comment explaining why the 6000-char total embed limit is safe: title (256) + description (4096) + footer (~30) < 6000


What this PR does
Fixes the Discord notification formatting where the alert message text appears above the embed title instead of below it.
The root cause is that the v1 Discord notifier places the message in the webhook's top-level
contentfield, which Discord renders above all embeds. The fix moves the message to the embed'sdescriptionfield, which renders below the title within the embed -- matching the behavior of Slack and other notification channels.Changes
Descriptionfield todiscordLinkEmbedstructlinkEmbed.Descriptioninstead ofmsg.ContentBefore
After
Note: The
v0mimir1Discord notifier already usesDescriptioncorrectly. This fix alignsv1with the same pattern.Which issue(s) this PR fixes
Fixes grafana/grafana#86565
Checklist
v0mimir1behavior)Note
Medium Risk
Moderate risk because it changes the Discord webhook payload structure and truncation limits, which can affect message rendering and any consumers expecting
contentto be populated.Overview
Discord v1 notifications now render the alert message inside the embed by adding an embed
descriptionfield and populating it with the templated message, leaving top-levelcontentempty so text no longer appears above the title.Message truncation is updated to Discord’s embed description limit (
4096runes), and tests are adjusted (including image/embedded quota cases) to assert the new payload shape and truncation behavior.Reviewed by Cursor Bugbot for commit 41901d4. Bugbot is set up for automated code reviews on this repo. Configure here.