Repository navigation
fix(reports): carry the report's native filters in the email and Slack link - #46062
Conversation
The dashboard link in report emails and Slack messages was built from the raw stored dashboard state, so it opened the dashboard's default filters rather than the filters applied to the attachment. Build it with the same URL builder used for screenshots so tab, urlParams and native filters match, and de-duplicate execution warnings now that the builder runs more than once. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… is empty An anchor of "[]" passes report validation but yields no tab URLs, so the call-to-action link raised IndexError and broke notifications, including failure notifications. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #46062 +/- ##
==========================================
- Coverage 85.92% 85.45% -0.48%
==========================================
Files 3122 3098 -24
Lines 216878 214218 -2660
Branches 51422 50199 -1223
==========================================
- Hits 186362 183059 -3303
- Misses 27098 27742 +644
+ Partials 3418 3417 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rebenitez1802
left a comment
There was a problem hiding this comment.
Approve: the CTA link now goes through the same URL builder as the attachment, so recipients land on the report's tab and filters. I checked this end to end by decoding the emailed permalink for a single tab, multiple tabs and with the flag off. There are no blockers and no security impact: the permalink still re-checks dashboard access, and RLS still applies to whoever opens it. Tests pass after merging current master, and filter values that need quoting come through intact with #46060.
🟡 Medium: new tests break when combined with #46063
#46063 makes _get_tab_url resolve the executor, and it adds @pytest.mark.usefixtures("resolvable_executor") to the existing permalink tests. The 8 new _get_url tests here reach _get_tab_url without that fixture. With both PRs merged, they fail with ReportScheduleExecutorNotFoundError. Production code combines fine. Fix: whichever PR lands second adds the fixture to the other's new tests.
The other notes are inline. None of them block.
| # stateful permalink (tab, urlParams and the report's native filters) | ||
| # as the attachment. A multi-tab report links to its first tab. | ||
| if not (user_friendly and attachment_free_alert): | ||
| urls = self.get_dashboard_urls(user_friendly=user_friendly, **kwargs) |
There was a problem hiding this comment.
🟡 Medium: the failure notification can be dropped when building the permalink fails
_get_failure_notification_url (L819-832) also goes through this branch, but it only catches ReportScheduleExecutorAccessDeniedError. With ALERT_REPORT_TABS off and native filters set, master's failure link was a plain URL that could not fail. It is now a permalink, so a DashboardPermalinkCreateFailedError, or a TypeError from a legacy filter shape, makes send_error raise, and the editors get no failure email. In an integration repro where creating the permalink succeeds in the pre-commit and then fails inside the run, master sent 1 email and this branch sent 0. Because it needs a transient failure, it's narrow.
The method is outside the diff, so I can't post an applyable suggestion. Proposed fix for _get_failure_notification_url (SoftTimeLimitExceeded and logger are already in scope):
try:
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)Regression test. It fails without the fix; with the fix the file passes 509/509:
@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 urlThere was a problem hiding this comment.
Thanks, valid. The failure link now goes through the permalink builder, so a transient permalink or legacy-filter error would have dropped the failure email. Added your regression test first (it failed with DashboardPermalinkCreateFailedError escaping _get_failure_notification_url), then applied your proposed fallback (SoftTimeLimitExceeded re-raised, other errors log a warning and fall back to the plain dashboard link, re-raise when there is no dashboard). Fixed in 2ae7765.
| # as the attachment. A multi-tab report links to its first tab. | ||
| if not (user_friendly and attachment_free_alert): | ||
| urls = self.get_dashboard_urls(user_friendly=user_friendly, **kwargs) | ||
| if urls: |
There was a problem hiding this comment.
🟢 Low: a multi-tab CTA builds N permalinks to use one
get_dashboard_urls(...)[0] runs a lookup, an access check and a commit for every tab, but only the first URL is used. Deterministic keys mean it writes no extra rows, so this is only wasted work. Not blocking.
There was a problem hiding this comment.
Agreed it is only wasted work. Leaving as is: building just the first tab URL would mean either duplicating the anchor/tab parsing from get_dashboard_urls or adding a "first tab only" mode to the shared screenshot path (_get_tabs_urls), and that is more surface area than the saving justifies for a non-blocking note. Reusing get_dashboard_urls keeps the CTA and the attachment guaranteed identical. Happy to revisit as a follow-up if the permalink lookups ever show up as a cost.
|
|
||
| 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() |
There was a problem hiding this comment.
🟢 Low: no test checks that user_friendly reaches get_dashboard_urls
If user_friendly is dropped from the get_dashboard_urls(...) call in _get_url, all 507 tests still pass, yet recipients would get internal WEBDRIVER_BASEURL links. This test passes on the current head and fails under that mutation:
| mock_permalink_cls.assert_not_called() | |
| 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/" | |
| ) |
There was a problem hiding this comment.
Thanks, added test_get_url_user_friendly_permalink_uses_user_friendly_host as suggested. Confirmed it fails when user_friendly is dropped from the get_dashboard_urls call in _get_url. Fixed in 2ae7765.
…link 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]>
|
Re the review note on #46063: understood. The Pushed 2ae7765 addressing the inline notes (failure-notification fallback + |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…-native-filters Keep both sides of the execute_test.py conflict: the CTA native-filter tests from this branch and the missing-executor tests from master, with a single shared resolvable_executor fixture applied to the CTA tests that now resolve an executor. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* origin/master: (393 commits) fix(a11y): name the semantic view description input (apache#46458) docs(semantic): explain datasource list modification eligibility (apache#46462) docs(semantic-layer): document NULL-preserving exclusion filters (apache#46447) fix(uploads): skip folder and system entries in columnar ZIP uploads (apache#45617) fix(i18n-es): promote 47 of the zero-context backfill entries (apache#45847) fix(mcp): return structured ChartError on SQLAlchemyError in get_chart_sql (apache#44351) fix(datasets): follow semantic view modification permissions (apache#46448) fix(docker): account for container memory limits in frontend-mem-nag.sh (apache#46373) fix(reports): carry the report's native filters in the email and Slack link (apache#46062) fix(explore): apply the dataset timezone to grained temporal filter values (apache#46175) fix(i18n): enforce the do-not-translate registry across the catalogs (apache#45974) chore(logging): log unparseable virtual dataset SQL at debug in the RLS lookup (apache#46139) fix(i18n): split parameter-suggestion plural into two messages (apache#46049) test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration (apache#46319) perf(dashboard): look up the dashboard once per filter_state read (apache#46314) fix(i18n): load the dayjs locale for every language with a catalog (apache#45982) test(semantic-layer): make date export parametrization deterministic (apache#46449) fix(oauth2): idempotent OAuth2 completion and resilient listener (apache#40292) fix(explore): prevent full table scan when SQL expression is used as x-axis (apache#41339) feat(mcp): radar chart type plugin (apache#43571) ... # Conflicts: # .github/workflows/docker.yml # .github/workflows/superset-frontend.yml
SUMMARY
For a dashboard report or alert with a tab and native filters (
ALERT_REPORTS_FILTER,ALERT_REPORT_TABS), the "Explore in Superset" call-to-action link in the email (and Slack message) opened the right tab but with the dashboard's default filters, not the report's. Recipients who clicked through saw different numbers than the attachment.Root cause:
_get_notification_contentbuilds the link with_get_url(user_friendly=True). Its dashboard branch created the permalink straight from the raw storedextra["dashboard"]state and never merged the report's native filters into the permalinkurlParams. The screenshot path goes throughget_dashboard_urls, which does merge them (per tab), so the attachment was filtered and the link was not. A multi-tab anchor (a JSON list string) was also passed through as-is.Changes (
superset/commands/report/execute.py):_get_url's dashboard branch now returns the first URL fromget_dashboard_urls(user_friendly=..., **kwargs), so the link carries the same stateful permalink (tab,urlParamssuch asstandalone=true, and the report's native filters) as the attachment. A multi-tab report links to its first tab. WithALERT_REPORT_TABSoff, the link is the filtered permalink the screenshot path already produces."[]", which report validation accepts), it falls back to the plain dashboard link instead of failing the notification._get_failure_notification_url's fallback to the plain link when the executor cannot access the dashboard._add_execution_warningshelper so filter warnings are not recorded twice now that the URL builder can run more than once per execution.Note: link correctness for filter values containing quotes also depends on the separate fix for the rison quote encoding in
get_native_filters_params(#46060).TESTING INSTRUCTIONS
12 new tests use a real
ReportSchedulewith realistic filters (multi-word text, commas and quotes, a numeric range, a time range) and cover: the permalink state carryingnative_filters; JSON-list, bare and missing anchors;urlParamssuch asstandalone=truebeing preserved; the flag-off case; the empty-state plain URL; an empty anchor list; the attachment-free alert;_get_notification_content().url; warning de-duplication; and the failure-URL fallback. 8 of them fail on master; the rest guard unchanged behaviour (plain URL when there is no state, attachment-free alert, failure-URL fallback, de-duplication).Manual: create a dashboard report on a tab with native filters, run it, and open the email's link; the filter bar should show the report's filters.
ADDITIONAL INFORMATION
ALERT_REPORTS_FILTER,ALERT_REPORT_TABS🤖 Generated with Claude Code