From c26158ba9d70549f2413486a53bb0ea9c5b8f2e5 Mon Sep 17 00:00:00 2001 From: Michael Derynck Date: Tue, 30 Aug 2022 15:26:04 -0600 Subject: [PATCH] Check if notification policies is empty --- engine/apps/alerts/tasks/notify_group.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/apps/alerts/tasks/notify_group.py b/engine/apps/alerts/tasks/notify_group.py index 9803affb..0a748c33 100644 --- a/engine/apps/alerts/tasks/notify_group.py +++ b/engine/apps/alerts/tasks/notify_group.py @@ -62,12 +62,14 @@ def notify_group_task(alert_group_pk, escalation_policy_snapshot_order=None): user=user, important=escalation_policy_step == EscalationPolicy.STEP_NOTIFY_GROUP_IMPORTANT, ) - usergroup_notification_plan += "\n_{} (".format( - step.get_user_notification_message_for_thread_for_usergroup(user, notification_policies.first()) - ) + notification_channels = [] if notification_policies.filter(step=UserNotificationPolicy.Step.NOTIFY).count() == 0: usergroup_notification_plan += "Empty notifications" + else: + usergroup_notification_plan += "\n_{} (".format( + step.get_user_notification_message_for_thread_for_usergroup(user, notification_policies.first()) + ) for notification_policy in notification_policies: if notification_policy.step == UserNotificationPolicy.Step.NOTIFY: notification_channels.append(