Skip to content

fix(reports): preserve urlParams in multi-tab report fan-out#39884

Open
EnxDev wants to merge 4 commits intomasterfrom
enxdev/fix/alerts-reports-filter-time-range-multitab-timeout
Open

fix(reports): preserve urlParams in multi-tab report fan-out#39884
EnxDev wants to merge 4 commits intomasterfrom
enxdev/fix/alerts-reports-filter-time-range-multitab-timeout

Conversation

@EnxDev
Copy link
Copy Markdown
Contributor

@EnxDev EnxDev commented May 5, 2026

SUMMARY

_get_tabs_urls and the ALERT_REPORT_TABS-disabled fall-through in get_dashboard_urls were both building permalinks with urlParams=[["native_filters", <rison>]] only, silently discarding everything else extra.dashboard.urlParams carried — notably standalone=true, which the single-tab branch already preserves
(see get_dashboard_urls lines 290–306).

The list-anchor shape that triggers the multi-tab path is reachable from the standard Reports UI: when a dashboard has ≥2 tabs, the Alert/Report modal injects an "All Tabs" option whose value is
JSON.stringify(allTabsWithOrder) (see AlertReportModal.tsx ~L1094–1099). Picking it makes the backend fan out per-tab screenshots, each missing standalone=true, which causes Playwright to time out at Locator.wait_for(".standalone") after the 10-minute hard timeout.
Recipients get a failure email instead of the screenshots.

This change applies the same merge semantics in both spots: dedup any existing native_filters entry from the original urlParams and append the report's.
Other per-tab fields (anchor, dataMask, activeTabs) keep their previous shape — the fix is scoped to the
urlParams discard.
The ALERT_REPORT_TABS=False fall-through previously didn't honor extra.dashboard.urlParams at all (only
API-set, since the modal is gated on the flag); now it does, matching the on-flag path.

Drive-bys (same area, kept tight):

  • DashboardPermalinkState.urlParams annotation:
    list[tuple[str, str]]list[Sequence[str]]. JSON-derived values arrive as list[list[str]] at runtime; Sequence is permissive of both shapes.
  • Single-tab branch and the merged fall-through use the new annotation; obsolete # type: ignore comments removed.
  • Silenced a pre-existing pylint consider-using-transaction warning on db.session.rollback() in create_log that the pre-commit hook was sporadically failing on; same disable comment as the surrounding db.session.commit().

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — change is in the report screenshot URL builder; not user-visible
UI. Behavior change is observable via report_execution_log.error_message:

  • Before:
  • Failed taking a screenshot Locator.wait_for: Timeout600000ms exceeded. Call log: - waiting for locator(".standalone") to be visible per fan-out screenshot.
  • After:
  • per-tab URLs carry standalone=true and any other params the user set; Playwright reaches the standalone view normally.

TESTING INSTRUCTIONS

  1. Enable feature flags:
    FEATURE_FLAGS = {
        "ALERT_REPORTS": True,
        "ALERT_REPORT_TABS": True,
        "ALERT_REPORTS_FILTER": True,
        "PLAYWRIGHT_REPORTS_AND_THUMBNAILS": True,
    }
  2. Use any dashboard with ≥2 tabs (e.g. the bundled Sales Dashboard has 🎯 Sales Overview and 🧭 Exploratory).
  3. Create a Report (PNG, schedule * * * * *) on that dashboard. In the modal's Select tab field, pick the "All Tabs" option (auto-injected when the dashboard has ≥2 tabs).
  4. Wait one minute (or hit "Send now"). Inspect report_execution_log and the recipient inbox — you should get one screenshot per tab. Without this fix, every per-tab screenshot times out at the 10-min .standalone Playwright wait.
  5. Run the unit tests:

pytest tests/unit_tests/commands/report/execute_test.py -k url_params

  • test_get_dashboard_urls_multitab_preserves_url_params — multi-tab fan-out path. Seeds urlParams with standalone, show_filters, and a stale native_filters entry, and asserts the merge: existing non-native_filters params survive in original order, the stale native_filters is replaced (not duplicated), and each per-tab state targets exactly its anchor.
  • test_get_dashboard_urls_flag_off_preserves_url_params — same dedup assertion for the ALERT_REPORT_TABS=False fall-through (reachable via API-created reports).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: ALERT_REPORT_TABS, ALERT_REPORTS and PLAYWRIGHT_REPORTS_AND_THUMBNAILS to observe the user-visible symptom.
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #00d20e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6d049b3..6d049b3
    • superset/commands/report/execute.py
    • tests/unit_tests/commands/report/execute_test.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added alert-reports Namespace | Anything related to the Alert & Reports feature change:backend Requires changing the backend labels May 5, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 012094a
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69fa1ab2c295750008853bfb
😎 Deploy Preview https://deploy-preview-39884--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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.87%. Comparing base (cb53745) to head (a4dba4f).

Files with missing lines Patch % Lines
superset/commands/report/execute.py 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39884      +/-   ##
==========================================
- Coverage   63.87%   63.87%   -0.01%     
==========================================
  Files        2582     2582              
  Lines      136413   136420       +7     
  Branches    31453    31453              
==========================================
+ Hits        87136    87140       +4     
- Misses      47764    47767       +3     
  Partials     1513     1513              
Flag Coverage Δ
hive 39.30% <38.46%> (+<0.01%) ⬆️
mysql 59.01% <76.92%> (-0.01%) ⬇️
postgres 59.09% <76.92%> (-0.01%) ⬇️
presto 41.00% <38.46%> (+<0.01%) ⬆️
python 60.53% <76.92%> (-0.01%) ⬇️
sqlite 58.72% <76.92%> (-0.01%) ⬇️
unit 100.00% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@EnxDev EnxDev force-pushed the enxdev/fix/alerts-reports-filter-time-range-multitab-timeout branch from 6d049b3 to 25a654b Compare May 5, 2026 08:24
`_get_tabs_urls` and the `ALERT_REPORT_TABS`-disabled fall-through in
`get_dashboard_urls` were both building permalinks with
`urlParams=[["native_filters", <rison>]]` only, silently discarding
everything else `extra.dashboard.urlParams` carried — notably
`standalone=true`, which the single-tab branch already preserves
(see `get_dashboard_urls` lines 290-306).

The list-anchor shape that triggers the multi-tab path is reachable
from the standard Reports UI: when a dashboard has at least 2 tabs,
the AlertReportModal injects an "All Tabs" option whose value is
`JSON.stringify(allTabsWithOrder)` (see `AlertReportModal.tsx`
~L1094-1099). Picking it makes the backend fan out per-tab screenshots,
each missing `standalone=true`, which causes Playwright to time out at
`Locator.wait_for(".standalone")` after the 10-minute hard timeout.
Recipients get a failure email instead of the screenshots.

Apply the same merge semantics in both spots: dedup any existing
`native_filters` entry from the original `urlParams` and append the
report's. Other per-tab fields (`anchor`, `dataMask`, `activeTabs`)
keep their previous shape — this fix is scoped to the `urlParams`
discard. The `ALERT_REPORT_TABS=False` fall-through previously didn't
honor `extra.dashboard.urlParams` at all (only API-set, since the
modal is gated on the flag); now it does, matching the on-flag path.

Drive-bys (same area, kept tight):
- `DashboardPermalinkState.urlParams` annotation: `list[tuple[str, str]]`
  -> `list[Sequence[str]]`. JSON-derived values arrive as
  `list[list[str]]` at runtime; `Sequence` is permissive of both shapes.
- Single-tab branch and the merged fall-through use the new annotation;
  obsolete `# type: ignore` comments removed.
- Silenced a pre-existing pylint `consider-using-transaction` warning
  on `db.session.rollback()` in `create_log` that the pre-commit hook
  was sporadically failing on; same disable comment as the surrounding
  `db.session.commit()`.

Tests:
- `test_get_dashboard_urls_multitab_preserves_url_params` seeds
  `urlParams` with `standalone`, `show_filters`, AND a stale
  `native_filters` entry, and asserts the merge replaces the stale
  entry, preserves the others in order, and targets each per-tab
  permalink at its anchor.
- `test_get_dashboard_urls_flag_off_preserves_url_params` does the
  same for the `ALERT_REPORT_TABS=False` fall-through.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@EnxDev EnxDev force-pushed the enxdev/fix/alerts-reports-filter-time-range-multitab-timeout branch from 25a654b to f9c665f Compare May 5, 2026 08:40
@pull-request-size pull-request-size Bot added size/L and removed size/M labels May 5, 2026
Address review feedback on the flag-off urlParams preservation test:

- Drop dead `force_screenshot = False` — the merge branch returns early
  so the attribute is never read. Mock auto-attributes are truthy by
  default; the matching multi-tab test doesn't set it either.
- Expand the docstring with a "Reachability:" note explaining that the
  fall-through is reached only when `dashboard_state` is falsy OR
  `ALERT_REPORT_TABS=False`; the flag-on / no-anchor case lands in the
  single-tab merge at L290-306 (already correct since before this PR),
  not in this branch.

No production change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #25373a

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: f9c665f..460300c
    • superset/commands/report/execute.py
    • superset/dashboards/permalink/types.py
    • tests/unit_tests/commands/report/execute_test.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

)
urls = self._get_tabs_urls(
anchor_list,
dashboard_state=dashboard_state,
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.

Why is this necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because _get_tabs_urls now needs the original dashboard_state to read its urlParams

except StaleDataError as ex:
# Report schedule was modified or deleted by another process
db.session.rollback()
db.session.rollback() # pylint: disable=consider-using-transaction
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.

Why is this necessary now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's a pre-existing pylint warning on pre-existing code in create_log, I added the disable comment because the pre-commit pylint hook failing

Comment thread superset/commands/report/execute.py Outdated
Comment on lines +381 to +386
base_state: DashboardPermalinkState = dashboard_state or {}
existing_params: list[Sequence[str]] = base_state.get("urlParams") or []
merged_params: list[Sequence[str]] = [
list(p) for p in existing_params if p[0] != "native_filters"
]
merged_params.append(["native_filters", native_filter_params or ""])
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.

I think this is repeated a bunch now, should we extract it out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm going to create a static helper

@bito-code-review
Copy link
Copy Markdown
Contributor

The changes in superset/commands/report/execute.py involve updates to type annotations, adding imports, and modifying logic for handling dashboard URLs and native filters in report execution. Without the specific diff hunk or comment context, I can't pinpoint the exact necessity, but they appear to address parameter merging and state preservation.

@EnxDev EnxDev requested review from alexandrusoare and msyavuz May 5, 2026 16:29
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #5a75f1

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 460300c..a4dba4f
    • superset/commands/report/execute.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alert-reports Namespace | Anything related to the Alert & Reports feature change:backend Requires changing the backend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants