From 396d28156d0a1b85ada8060ea06c32d1d7f23644 Mon Sep 17 00:00:00 2001 From: Kunal Gupta <39487888+iamKunalGupta@users.noreply.github.com> Date: Wed, 13 Mar 2024 00:38:01 +0530 Subject: [PATCH] fix: set reply to as source if not present --- flow/alerting/alerting.go | 11 ++--------- flow/alerting/email_alert_sender.go | 6 +++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/flow/alerting/alerting.go b/flow/alerting/alerting.go index 2ac0830ee..b62e34df9 100644 --- a/flow/alerting/alerting.go +++ b/flow/alerting/alerting.go @@ -52,17 +52,10 @@ func (a *Alerter) registerSendersFromPool(ctx context.Context) ([]AlertSenderCon alertSenderConfigs = append(alertSenderConfigs, AlertSenderConfig{Id: id, Sender: newSlackAlertSender(&slackServiceConfig)}) case EMAIL: - var replyToAddresses []string - if envReplyToAddresses := strings.Split(peerdbenv.PeerDBAlertingEmailSenderReplyToAddresses(), ","); len(envReplyToAddresses) != 0 { - // AWS SDK does not like empty slice - replyToAddresses = envReplyToAddresses - } else { - replyToAddresses = nil - } emailServiceConfig := EmailAlertSenderConfig{ sourceEmail: peerdbenv.PeerDBAlertingEmailSenderSourceEmail(), configurationSetName: peerdbenv.PeerDBAlertingEmailSenderConfigurationSet(), - replyToAddresses: replyToAddresses, + replyToAddresses: strings.Split(peerdbenv.PeerDBAlertingEmailSenderReplyToAddresses(), ","), } if emailServiceConfig.sourceEmail == "" { return errors.New("missing sourceEmail for Email alerting service") @@ -247,7 +240,7 @@ func (a *Alerter) checkAndAddAlertToCatalog(ctx context.Context, alertConfigId i } logger.LoggerFromCtx(ctx).Info( - fmt.Sprintf("Skipeed sending alerts: last alert was sent at %s, which was >=%s ago", + fmt.Sprintf("Skipped sending alerts: last alert was sent at %s, which was >=%s ago", createdTimestamp.String(), dur.String())) return false } diff --git a/flow/alerting/email_alert_sender.go b/flow/alerting/email_alert_sender.go index 2a534318c..2862a3fb5 100644 --- a/flow/alerting/email_alert_sender.go +++ b/flow/alerting/email_alert_sender.go @@ -83,11 +83,15 @@ func NewEmailAlertSenderWithNewClient(ctx context.Context, region *string, confi } func NewEmailAlertSender(client *ses.Client, config *EmailAlertSenderConfig) *EmailAlertSender { + replyToAddresses := config.replyToAddresses + if len(replyToAddresses) == 0 { + replyToAddresses = []string{config.sourceEmail} + } return &EmailAlertSender{ client: client, sourceEmail: config.sourceEmail, configurationSetName: config.configurationSetName, - replyToAddresses: config.replyToAddresses, + replyToAddresses: replyToAddresses, slotLagMBAlertThreshold: config.SlotLagMBAlertThreshold, openConnectionsAlertThreshold: config.OpenConnectionsAlertThreshold, emailAddresses: config.EmailAddresses,