Skip to content

Commit bd031a3

Browse files
committed
fix: reconcile severity labels on all-clear reruns
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent bbe170f commit bd031a3

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

socket_basics/core/notification/manager.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,15 @@ def _alert_group(alert: Dict[str, Any], comp: Dict[str, Any]) -> str:
510510
notifier_data = per_notifier_notifications[notification_key]
511511
notifier_facts['notifications'] = notifier_data
512512
logger.debug('Using pre-formatted data for notifier %s: %s items', notifier_name, len(notifier_data) if isinstance(notifier_data, list) else 1)
513+
elif notification_key == 'github_pr':
514+
# GitHub PR label reconciliation still needs to run on "all clear"
515+
# reruns where there are no current notification sections.
516+
notifier_facts['notifications'] = []
517+
logger.debug(
518+
'No pre-formatted data found for notifier %s (key: %s); passing empty notifications for label reconciliation',
519+
notifier_name,
520+
notification_key,
521+
)
513522
else:
514523
# No pre-formatted data available - skip this notifier to avoid sending wrong format
515524
logger.debug('No pre-formatted data found for notifier %s (key: %s), skipping to avoid format mismatch', notifier_name, notification_key)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from socket_basics.core.notification.manager import NotificationManager
2+
3+
4+
class _DummyGithubPrNotifier:
5+
name = "github_pr"
6+
7+
def __init__(self):
8+
self.payloads = []
9+
10+
def notify(self, facts):
11+
self.payloads.append(facts)
12+
13+
14+
def test_notify_all_passes_empty_notifications_to_github_pr_for_all_clear():
15+
notifier = _DummyGithubPrNotifier()
16+
nm = NotificationManager({}, app_config={"repo": "SocketDev/socket-basics"})
17+
nm.notifiers = [notifier]
18+
19+
nm.notify_all({"components": [], "notifications": {}})
20+
21+
assert len(notifier.payloads) == 1
22+
assert notifier.payloads[0]["notifications"] == []

0 commit comments

Comments
 (0)