Populate messages for more receivers with ExtraData if present#483
Open
Populate messages for more receivers with ExtraData if present#483
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
Author
Consolidate the identical 5-line block that was duplicated across 8 receivers (email, mqtt, opsgenie, pagerduty, slack, webex, oncall, webhook) into a single shared helper function in the receivers package. This change: - Adds ApplyExtraData() helper function in receivers/util.go - Adds ExtraDataAlerts interface that templates.ExtendedAlerts implements - Adds Len() and SetExtraData() methods to templates.ExtendedAlerts - Replaces duplicate code in all 8 receivers with one-liner helper call This reduces code duplication and ensures consistent behavior across all receivers, making future changes easier to maintain. Applied via @cursor push command
|
|
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (b4f8d0ceed)diff --git a/receivers/email/v1/email.go b/receivers/email/v1/email.go
--- a/receivers/email/v1/email.go
+++ b/receivers/email/v1/email.go
@@ -41,6 +41,9 @@
var tmplErr error
tmpl, data := templates.TmplText(ctx, en.tmpl, alerts, l, &tmplErr)
+ // Augment extended Alert data with any extra data if provided.
+ receivers.ApplyExtraData(ctx, data.Alerts)
+
subject := tmpl(en.settings.Subject)
alertPageURL := en.tmpl.ExternalURL.String()
ruleURL := en.tmpl.ExternalURL.String()
@@ -85,9 +88,6 @@
level.Warn(l).Log("msg", "failed to get all images for email", "err", err)
}
- // Augment extended Alert data with any extra data if provided.
- receivers.ApplyExtraData(ctx, data.Alerts)
-
cmd := &receivers.SendEmailSettings{
Subject: subject,
Data: map[string]interface{}{ |
Collaborator
|
OpsGenie is deprecated. Let's leave it out of any new features. |
yuri-tceretian
approved these changes
Feb 11, 2026
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.

If there is
ExtraDatapresent in thectx, then adds it to the message payload for the following additional receivers:emailmqttopsgeniepagerdutyslackwebexNote
Low Risk
Small, additive change limited to notification payload composition; risk is mainly unintended template/payload differences if
ExtraDatais present or mismatched-length.Overview
ExtraData propagation is expanded and standardized across receivers.
email,mqtt,opsgenie,pagerduty,slack, andwebexnow call a sharedreceivers.ApplyExtraData(ctx, data.Alerts)helper so any per-alertExtraDatapresent in the context is available to templates/payloads.Refactors existing bespoke
ExtraDatainjection inoncallandwebhookto use the same helper, introduces a small interface (ExtraDataAlerts) plustemplates.ExtendedAlertsmethods (Len,SetExtraData) to support it, and adds newTestNotify_ExtraDatatests for the newly-supported receivers.Written by Cursor Bugbot for commit 060235e. This will update automatically on new commits. Configure here.