From c4733f4daacb858b6794be6ef4414af36204af28 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 5 Sep 2025 12:43:39 -0300 Subject: [PATCH 1/2] SIENTIAPDE-1182 SIENTIAPDE-1206: Add early return for empty receiver groups in Alerts workflow - Implemented an early return in the Alerts class to handle cases where no receiver groups are provided, preventing unnecessary processing in the notification workflow. --- orchestrator/workflows/alerts.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/orchestrator/workflows/alerts.py b/orchestrator/workflows/alerts.py index 64b3606..90cef34 100644 --- a/orchestrator/workflows/alerts.py +++ b/orchestrator/workflows/alerts.py @@ -70,6 +70,9 @@ class Alerts: retry_policy=retry_policy ) + if not receiver_groups: + return + # Call subworkflow "process_notifications" passing the notification package log_report = await workflow.execute_child_workflow( 'process_notifications', From 678c149cf2c66c5e66e7f518e4d72e5a68dfeec1 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 5 Sep 2025 12:57:59 -0300 Subject: [PATCH 2/2] SIENTIAPDE-1182 Add test for handling cases with no receiver groups in Alerts workflow - Implemented a new test case to verify the behavior of the Alerts workflow when no receiver groups are provided, ensuring that the workflow executes correctly without unnecessary processing. --- tests/orchestrator/workflows/test_alerts.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/orchestrator/workflows/test_alerts.py b/tests/orchestrator/workflows/test_alerts.py index 56c1406..37fa1b3 100644 --- a/tests/orchestrator/workflows/test_alerts.py +++ b/tests/orchestrator/workflows/test_alerts.py @@ -117,6 +117,22 @@ async def test_run_no_data(workflow_mock, alerts): workflow_mock.execute_local_activity_method.assert_not_called() +@mark.asyncio +@patch("orchestrator.workflows.alerts.workflow", new_callable=AsyncMock) +async def test_run_no_receiver_groups(workflow_mock, alerts): + workflow_mock.execute_local_activity_method.return_value = {} + + input_data = { + 'schedule_name': 'test-schedule-name', + 'notification_ttl': 300, + 'sent_ttl': 600 + } + + await alerts.run(input_data) + + assert workflow_mock.execute_child_workflow.call_count == 1 + + @mark.asyncio @patch("orchestrator.workflows.alerts.workflow", new_callable=AsyncMock) async def test_run_no_log_report(workflow_mock, alerts):