This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch fix-report-cta-link-native-filters
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to 
refs/heads/fix-report-cta-link-native-filters by this push:
     new 2ae7765b20e fix(reports): fall back to plain link when 
failure-notification permalink fails
2ae7765b20e is described below

commit 2ae7765b20e71c6800ca75443aedcb0a49eb52d9
Author: sadpandajoe <[email protected]>
AuthorDate: Fri Nov 13 12:22:10 2026 +0000

    fix(reports): fall back to plain link when failure-notification permalink 
fails
    
    The failure notification link now goes through the permalink builder, which
    can fail (permalink store error, legacy filter shape). That made send_error
    raise and dropped the failure email. Fall back to the plain dashboard link
    for any non-timeout error, and add tests for the fallback and for the
    user-friendly host reaching the permalink builder.
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 superset/commands/report/execute.py              | 15 +++++++++
 tests/unit_tests/commands/report/execute_test.py | 41 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/superset/commands/report/execute.py 
b/superset/commands/report/execute.py
index 598013d20e4..65d9eb17d7b 100644
--- a/superset/commands/report/execute.py
+++ b/superset/commands/report/execute.py
@@ -830,6 +830,21 @@ class BaseReportState:
             return self._get_url(user_friendly=True)
         except ReportScheduleExecutorAccessDeniedError:
             return self._get_plain_dashboard_url(user_friendly=True)
+        except SoftTimeLimitExceeded:
+            raise
+        except Exception:  # pylint: disable=broad-except
+            # Building the stateful link can fail for the very reason the
+            # report failed (e.g. the permalink store or the saved native
+            # filters). The editors still need to hear about the failure.
+            if self._report_schedule.dashboard is None:
+                raise
+            logger.warning(
+                "Falling back to the plain dashboard link for the failure "
+                "notification of report schedule %s",
+                self._report_schedule.id,
+                exc_info=True,
+            )
+            return self._get_plain_dashboard_url(user_friendly=True)
 
     def _raise_for_executor_dashboard_access(self) -> None:
         """
diff --git a/tests/unit_tests/commands/report/execute_test.py 
b/tests/unit_tests/commands/report/execute_test.py
index 3eab9368523..e56d74ac96e 100644
--- a/tests/unit_tests/commands/report/execute_test.py
+++ b/tests/unit_tests/commands/report/execute_test.py
@@ -6524,3 +6524,44 @@ def 
test_get_url_user_friendly_empty_anchor_list_falls_back_to_plain_url(
     assert "/dashboard/11111111-1111-1111-1111-111111111111" in url
     assert "/dashboard/11111111-1111-1111-1111-111111111111" in failure_url
     mock_permalink_cls.assert_not_called()
+
+
+@patch("superset.commands.report.execute.CreateDashboardPermalinkCommand")
+@with_feature_flags(ALERT_REPORT_TABS=True)
+def test_get_url_user_friendly_permalink_uses_user_friendly_host(
+    mock_permalink_cls, mocker: MockerFixture, app
+) -> None:
+    mock_permalink_cls.return_value.run.return_value = "key1"
+    mocker.patch.dict(
+        app.config,
+        {
+            "WEBDRIVER_BASEURL": "http://internal:8088/";,
+            "WEBDRIVER_BASEURL_USER_FRIENDLY": "https://superset.example.com/";,
+        },
+    )
+    state = _dashboard_cta_state(
+        mocker, {"anchor": "TAB-1", "nativeFilters": REALISTIC_NATIVE_FILTERS}
+    )
+
+    assert state._get_url(user_friendly=True).startswith(
+        "https://superset.example.com/dashboard/p/key1/";
+    )
+
+
+@patch("superset.commands.report.execute.CreateDashboardPermalinkCommand")
+@with_feature_flags(ALERT_REPORT_TABS=False)
+def test_failure_notification_url_falls_back_when_permalink_fails(
+    mock_permalink_cls, mocker: MockerFixture, app
+) -> None:
+    from superset.dashboards.permalink.exceptions import (
+        DashboardPermalinkCreateFailedError,
+    )
+
+    mock_permalink_cls.return_value.run.side_effect = (
+        DashboardPermalinkCreateFailedError()
+    )
+    state = _dashboard_cta_state(mocker, {"nativeFilters": 
REALISTIC_NATIVE_FILTERS})
+
+    url = state._get_failure_notification_url()
+
+    assert "/dashboard/11111111-1111-1111-1111-111111111111" in url

Reply via email to