From c26158ba9d70549f2413486a53bb0ea9c5b8f2e5 Mon Sep 17 00:00:00 2001 From: Michael Derynck Date: Tue, 30 Aug 2022 15:26:04 -0600 Subject: [PATCH 1/3] 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( From 53b9bb638c42c94e4db3fa359a163bd2e17581a1 Mon Sep 17 00:00:00 2001 From: Michael Derynck Date: Tue, 30 Aug 2022 15:29:10 -0600 Subject: [PATCH 2/3] Check if notification policies is empty --- engine/apps/alerts/tasks/notify_group.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/apps/alerts/tasks/notify_group.py b/engine/apps/alerts/tasks/notify_group.py index 0a748c33..a3de0b9f 100644 --- a/engine/apps/alerts/tasks/notify_group.py +++ b/engine/apps/alerts/tasks/notify_group.py @@ -63,13 +63,15 @@ def notify_group_task(alert_group_pk, escalation_policy_snapshot_order=None): important=escalation_policy_step == EscalationPolicy.STEP_NOTIFY_GROUP_IMPORTANT, ) - notification_channels = [] - if notification_policies.filter(step=UserNotificationPolicy.Step.NOTIFY).count() == 0: - usergroup_notification_plan += "Empty notifications" - else: + if notification_policies: 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" + for notification_policy in notification_policies: if notification_policy.step == UserNotificationPolicy.Step.NOTIFY: notification_channels.append( From b71b92e8dd1a27534c94549e9ff14f3a2d8a42b7 Mon Sep 17 00:00:00 2001 From: Michael Derynck Date: Wed, 31 Aug 2022 12:29:56 -0600 Subject: [PATCH 3/3] Update changelog for v1.0.30 --- CHANGELOG.md | 5 ++++- grafana-plugin/CHANGELOG.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6545f14f..b028104c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## v1.0.30 (2022-08-31) +- Bug fix: check user notification policy before access + ## v1.0.29 (2022-08-31) - Add arm64 docker image @@ -82,7 +85,7 @@ ## 1.0.2 (2022-06-17) - Fix Grafana Alerting integration to handle API changes in Grafana 9 -- Improve public api endpoint for for outgoing webhooks (/actions) by adding ability to create, update and delete outgoing webhook instance +- Improve public api endpoint for outgoing webhooks (/actions) by adding ability to create, update and delete outgoing webhook instance ## 1.0.0 (2022-06-14) diff --git a/grafana-plugin/CHANGELOG.md b/grafana-plugin/CHANGELOG.md index 6545f14f..b028104c 100644 --- a/grafana-plugin/CHANGELOG.md +++ b/grafana-plugin/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## v1.0.30 (2022-08-31) +- Bug fix: check user notification policy before access + ## v1.0.29 (2022-08-31) - Add arm64 docker image @@ -82,7 +85,7 @@ ## 1.0.2 (2022-06-17) - Fix Grafana Alerting integration to handle API changes in Grafana 9 -- Improve public api endpoint for for outgoing webhooks (/actions) by adding ability to create, update and delete outgoing webhook instance +- Improve public api endpoint for outgoing webhooks (/actions) by adding ability to create, update and delete outgoing webhook instance ## 1.0.0 (2022-06-14)