Skip to content

Populate messages for more receivers with ExtraData if present#483

Open
fayzal-g wants to merge 3 commits intomainfrom
extra-data-rcvs
Open

Populate messages for more receivers with ExtraData if present#483
fayzal-g wants to merge 3 commits intomainfrom
extra-data-rcvs

Conversation

@fayzal-g
Copy link
Contributor

@fayzal-g fayzal-g commented Feb 11, 2026

If there is ExtraData present in the ctx, then adds it to the message payload for the following additional receivers:

  • email
  • mqtt
  • opsgenie
  • pagerduty
  • slack
  • webex

Note

Low Risk
Small, additive change limited to notification payload composition; risk is mainly unintended template/payload differences if ExtraData is present or mismatched-length.

Overview
ExtraData propagation is expanded and standardized across receivers. email, mqtt, opsgenie, pagerduty, slack, and webex now call a shared receivers.ApplyExtraData(ctx, data.Alerts) helper so any per-alert ExtraData present in the context is available to templates/payloads.

Refactors existing bespoke ExtraData injection in oncall and webhook to use the same helper, introduces a small interface (ExtraDataAlerts) plus templates.ExtendedAlerts methods (Len, SetExtraData) to support it, and adds new TestNotify_ExtraData tests for the newly-supported receivers.

Written by Cursor Bugbot for commit 060235e. This will update automatically on new commits. Configure here.

@fayzal-g fayzal-g requested a review from a team as a code owner February 11, 2026 12:28
@github-project-automation github-project-automation bot moved this to In review in Alerting Feb 11, 2026
@cursor

This comment has been minimized.

@fayzal-g
Copy link
Contributor Author

@cursor push e4c2cec

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
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ fayzal-g
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

@cursor
Copy link

cursor bot commented Feb 11, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: Email subject template lacks access to ExtraData
    • Moved ApplyExtraData call to immediately after TmplText and before any tmpl() calls, ensuring ExtraData is available when the subject template is executed.

Create PR

Or push these changes by commenting:

@cursor push b4f8d0ceed
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{}{

@yuri-tceretian
Copy link
Collaborator

OpsGenie is deprecated. Let's leave it out of any new features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants