diff --git a/pkg/services/ngalert/notifier/sender.go b/pkg/services/ngalert/notifier/sender.go index aa8bc76051c..0c3dbc5205b 100644 --- a/pkg/services/ngalert/notifier/sender.go +++ b/pkg/services/ngalert/notifier/sender.go @@ -24,7 +24,7 @@ type emailSender struct { // isPlaceholderEmail checks if the given email address is a placeholder that should not be sent func isPlaceholderEmail(email string) bool { trimmed := strings.TrimSpace(email) - return trimmed == placeholderEmailAddress || trimmed == "example@email.com" + return trimmed == placeholderEmailAddress } func (s emailSender) SendEmail(ctx context.Context, cmd *receivers.SendEmailSettings) error { diff --git a/pkg/services/ngalert/notifier/sender_test.go b/pkg/services/ngalert/notifier/sender_test.go index 450c9da37c8..6bc5000f8dd 100644 --- a/pkg/services/ngalert/notifier/sender_test.go +++ b/pkg/services/ngalert/notifier/sender_test.go @@ -18,21 +18,21 @@ func TestIsPlaceholderEmail(t *testing.T) { email string expected bool }{ - { - name: "placeholder with angle brackets", - email: "", - expected: true, - }, - { - name: "placeholder without angle brackets", - email: "example@email.com", - expected: true, - }, - { - name: "placeholder with spaces", - email: " ", - expected: true, - }, + { + name: "placeholder with angle brackets", + email: "", + expected: true, + }, + { + name: "not a placeholder - example@email.com without angle brackets", + email: "example@email.com", + expected: false, + }, + { + name: "placeholder with spaces", + email: " ", + expected: true, + }, { name: "valid email", email: "user@example.com", @@ -118,20 +118,20 @@ func TestEmailSender_SendEmail_PlaceholderHandling(t *testing.T) { expectedRecips: []string{"user@example.com", "admin@grafana.com"}, description: "Should send to all valid addresses", }, - { - name: "multiple placeholders with one valid", - recipients: []string{"example@email.com", "", "valid@example.com"}, - expectSend: true, - expectedRecips: []string{"valid@example.com"}, - description: "Should filter out all placeholder variations and send to valid address", - }, - { - name: "only placeholders without angle brackets", - recipients: []string{"example@email.com"}, - expectSend: false, - expectedRecips: nil, - description: "Should skip sending when placeholder is without angle brackets", - }, + { + name: "placeholder with angle brackets filtered, others sent", + recipients: []string{"example@email.com", "", "valid@example.com"}, + expectSend: true, + expectedRecips: []string{"example@email.com", "valid@example.com"}, + description: "Should filter out only placeholder with angle brackets and send to other addresses", + }, + { + name: "example@email.com without angle brackets is valid", + recipients: []string{"example@email.com"}, + expectSend: true, + expectedRecips: []string{"example@email.com"}, + description: "Should send to example@email.com when it doesn't have angle brackets", + }, } for _, tt := range tests { diff --git a/public/app/features/alerting/unified/utils/receiver-form.ts b/public/app/features/alerting/unified/utils/receiver-form.ts index 39be513d334..b778fe7b01a 100644 --- a/public/app/features/alerting/unified/utils/receiver-form.ts +++ b/public/app/features/alerting/unified/utils/receiver-form.ts @@ -309,7 +309,7 @@ export function omitTemporaryIdentifiers(object: Readonly): T { * Placeholder emails that ship with the default grafana-default-email contact point. * These should not trigger actual email sends or throw errors. */ -const PLACEHOLDER_EMAILS = ['', 'example@email.com']; +const PLACEHOLDER_EMAILS = ['']; /** * Check if a single channel/integration has placeholder email addresses.