diff --git a/superset/commands/report/execute.py b/superset/commands/report/execute.py index e51b9684dd53..443299f61f9e 100644 --- a/superset/commands/report/execute.py +++ b/superset/commands/report/execute.py @@ -507,6 +507,7 @@ def _get_log_data(self) -> HeaderDataType: "dashboard_id": dashboard_id, "owners": self._report_schedule.owners, "slack_channels": slack_channels, + "execution_id": str(self._execution_id), } return log_data diff --git a/superset/reports/notifications/email.py b/superset/reports/notifications/email.py index 22a0d38bdd60..052ca610117c 100644 --- a/superset/reports/notifications/email.py +++ b/superset/reports/notifications/email.py @@ -253,7 +253,11 @@ def send(self) -> None: header_data=content.header_data, ) logger.info( - "Report sent to email, notification content is %s", content.header_data + "Report sent to email, task_id: %s, notification content is %s", + content.header_data.get("execution_id") + if content.header_data + else None, + content.header_data, ) except SupersetErrorsException as ex: raise NotificationError( diff --git a/superset/utils/core.py b/superset/utils/core.py index d4a3806e92b0..aba71e2b3ebc 100644 --- a/superset/utils/core.py +++ b/superset/utils/core.py @@ -216,6 +216,7 @@ class HeaderDataType(TypedDict): chart_id: int | None dashboard_id: int | None slack_channels: list[str] | None + execution_id: str | None class DatasourceDict(TypedDict): diff --git a/tests/integration_tests/reports/commands/execute_dashboard_report_tests.py b/tests/integration_tests/reports/commands/execute_dashboard_report_tests.py index 6c1b607279e8..e3624272d183 100644 --- a/tests/integration_tests/reports/commands/execute_dashboard_report_tests.py +++ b/tests/integration_tests/reports/commands/execute_dashboard_report_tests.py @@ -117,4 +117,4 @@ def test_report_with_header_data( assert header_data.get("notification_format") == report_schedule.report_format assert header_data.get("notification_source") == ReportSourceFormat.DASHBOARD assert header_data.get("notification_type") == report_schedule.type - assert len(send_email_smtp_mock.call_args.kwargs["header_data"]) == 7 + assert len(send_email_smtp_mock.call_args.kwargs["header_data"]) == 8 diff --git a/tests/unit_tests/commands/report/execute_test.py b/tests/unit_tests/commands/report/execute_test.py index 86b92a2cb76a..b2481be1bb37 100644 --- a/tests/unit_tests/commands/report/execute_test.py +++ b/tests/unit_tests/commands/report/execute_test.py @@ -64,6 +64,7 @@ def test_log_data_with_chart(mocker: MockerFixture) -> None: "dashboard_id": None, "owners": [1, 2], "slack_channels": None, + "execution_id": "execution_id_example", } assert result == expected_result @@ -94,6 +95,7 @@ def test_log_data_with_dashboard(mocker: MockerFixture) -> None: "dashboard_id": 123, "owners": [1, 2], "slack_channels": None, + "execution_id": "execution_id_example", } assert result == expected_result @@ -128,6 +130,7 @@ def test_log_data_with_email_recipients(mocker: MockerFixture) -> None: "dashboard_id": 123, "owners": [1, 2], "slack_channels": [], + "execution_id": "execution_id_example", } assert result == expected_result @@ -162,6 +165,7 @@ def test_log_data_with_slack_recipients(mocker: MockerFixture) -> None: "dashboard_id": 123, "owners": [1, 2], "slack_channels": ["channel_1", "channel_2"], + "execution_id": "execution_id_example", } assert result == expected_result @@ -195,6 +199,7 @@ def test_log_data_no_owners(mocker: MockerFixture) -> None: "dashboard_id": 123, "owners": [], "slack_channels": ["channel_1", "channel_2"], + "execution_id": "execution_id_example", } assert result == expected_result @@ -230,6 +235,7 @@ def test_log_data_with_missing_values(mocker: MockerFixture) -> None: "dashboard_id": None, "owners": [1, 2], "slack_channels": ["channel_1", "channel_2"], + "execution_id": "execution_id_example", } assert result == expected_result diff --git a/tests/unit_tests/reports/notifications/email_tests.py b/tests/unit_tests/reports/notifications/email_tests.py index d8872d4d3490..e2e0eeb29907 100644 --- a/tests/unit_tests/reports/notifications/email_tests.py +++ b/tests/unit_tests/reports/notifications/email_tests.py @@ -47,6 +47,7 @@ def test_render_description_with_html() -> None: "chart_id": None, "dashboard_id": None, "slack_channels": None, + "execution_id": "test-execution-id", }, ) email_body = ( @@ -91,6 +92,7 @@ def test_email_subject_with_datetime() -> None: "chart_id": None, "dashboard_id": None, "slack_channels": None, + "execution_id": "test-execution-id", }, ) subject = EmailNotification( diff --git a/tests/unit_tests/reports/notifications/slack_tests.py b/tests/unit_tests/reports/notifications/slack_tests.py index 3c7b12308af1..1457544ec7e9 100644 --- a/tests/unit_tests/reports/notifications/slack_tests.py +++ b/tests/unit_tests/reports/notifications/slack_tests.py @@ -36,6 +36,7 @@ def mock_header_data() -> HeaderDataType: "chart_id": None, "dashboard_id": None, "slack_channels": ["some_channel"], + "execution_id": "test-execution-id", }