Skip to content

fix(reports): carry the report's native filters in the email and Slack link - #46062

Merged
eschutho merged 7 commits into
masterfrom
fix-report-cta-link-native-filters
Nov 22, 2026
Merged

eschutho merged 7 commits into
masterfrom
fix-report-cta-link-native-filters

Conversation

@eschutho

@eschutho eschutho commented Nov 7, 2026

Copy link
Copy Markdown
Member

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_content builds the link with _get_url(user_friendly=True). Its dashboard branch created the permalink straight from the raw stored extra["dashboard"] state and never merged the report's native filters into the permalink urlParams. The screenshot path goes through get_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 from get_dashboard_urls(user_friendly=..., **kwargs), so the link carries the same stateful permalink (tab, urlParams such as standalone=true, and the report's native filters) as the attachment. A multi-tab report links to its first tab. With ALERT_REPORT_TABS off, the link is the filtered permalink the screenshot path already produces.
  • If no tab URLs come back (an empty tab list, "[]", which report validation accepts), it falls back to the plain dashboard link instead of failing the notification.
  • Unchanged: the attachment-free-alert bare dashboard link, the up-front chart/dashboard guards, chart-only callers, and _get_failure_notification_url's fallback to the plain link when the executor cannot access the dashboard.
  • New _add_execution_warnings helper 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

pytest tests/unit_tests/commands/report/execute_test.py

12 new tests use a real ReportSchedule with realistic filters (multi-word text, commas and quotes, a numeric range, a time range) and cover: the permalink state carrying native_filters; JSON-list, bare and missing anchors; urlParams such as standalone=true being 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

  • Has associated issue:
  • Required feature flags: ALERT_REPORTS_FILTER, ALERT_REPORT_TABS
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

eschutho and others added 2 commits November 7, 2026 00:45
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

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.45%. Comparing base (45f1aa7) to head (9775026).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
superset/commands/report/execute.py 53.33% 7 Missing ⚠️
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     
Flag Coverage Δ
hive 33.88% <6.66%> (-0.01%) ⬇️
mysql 51.56% <40.00%> (-0.01%) ⬇️
postgres 51.59% <40.00%> (-0.01%) ⬇️
presto 35.55% <6.66%> (-0.01%) ⬇️
python 88.42% <53.33%> (-0.01%) ⬇️
sqlite 51.26% <40.00%> (-0.01%) ⬇️
unit 83.84% <53.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sadpandajoe
sadpandajoe marked this pull request as ready for review November 12, 2026 22:46
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 9775026479e4

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 url

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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:

Suggested change
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/"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@sadpandajoe

Copy link
Copy Markdown
Member

Re the review note on #46063: understood. The resolvable_executor fixture does not exist on this PR base, so I am not adding it here. Whichever of #46062 / #46063 lands second will add @pytest.mark.usefixtures("resolvable_executor") to the other PR's new tests (the 8 new _get_url tests here that reach _get_tab_url). Production code combines fine, as noted.

Pushed 2ae7765 addressing the inline notes (failure-notification fallback + user_friendly test); the multi-tab permalink note is acknowledged, no change.

@netlify

netlify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 268873b
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6b01e0c05f50b126959b2510
😎 Deploy Preview https://deploy-preview-46062--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Nov 21, 2026
…-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]>
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Nov 21, 2026
@eschutho
eschutho merged commit 5ef84de into master Nov 22, 2026
76 checks passed
@eschutho
eschutho deleted the fix-report-cta-link-native-filters branch November 22, 2026 02:22
jprinet added a commit to jprinet/superset that referenced this pull request Nov 23, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants