Skip to content

feat(dashboard): download the Excel export directly when no export storage is configured - #44082

Merged
EnxDev merged 30 commits into
masterfrom
enxdev/feat/dashboard-excel-export-sync-fallback
Sep 27, 2026
Merged

EnxDev merged 30 commits into
masterfrom
enxdev/feat/dashboard-excel-export-sync-fallback

Conversation

@EnxDev

@EnxDev EnxDev commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

“Export Data to Excel” previously worked only when EXCEL_EXPORT_S3_BUCKET was configured. On deployments without a bucket, the menu item was still visible because it is controlled by the can_export permission, but the endpoint returned 501 and the user received an error toast.

The endpoint now selects the execution path based on the existing storage configuration:

  • Bucket configured: the existing asynchronous flow is unchanged. The export is queued through Celery, uploaded to storage, and emailed as a download link. The endpoint returns 202 with a job ID.
  • No bucket configured: the workbook is generated during the request and returned directly as a file download. This path does not require a Celery worker, export storage, or email delivery.

Execution-path selection

Availability is derived from the storage configuration rather than a separate feature flag. Adding a flag would create another setting that could disagree with the actual storage configuration.

The frontend does not choose the execution path. It sends the same request and handles either a synchronous file response or an asynchronous job response. This means changing the server configuration cannot leave the frontend requesting an unsupported path.

Synchronous export limit

The synchronous path checks the export size before running any query.

A new EXCEL_EXPORT_SYNC_MAX_ROWS configuration value, with a default of 100_000, limits the combined row_limit of every query the export would execute.

The synchronous export is refused with an actionable 400 response when:

  • the combined row limit exceeds the configured maximum; or
  • any query does not have a finite row limit.

The error explains that EXCEL_EXPORT_S3_BUCKET must be configured to run the export asynchronously.

The server request timeout remains a final safety mechanism, not the execution-path selector. Waiting for a timeout would waste work already performed and would not give the user an actionable explanation.

The export lock is acquired before query-context planning, so a duplicate request is rejected before it pays that cost. A budget refusal or planning failure releases the lock immediately.

Image exports remain asynchronous

mode=images is not supported by the synchronous path.

Image exports render charts through the headless webdriver, and their cost cannot be bounded by the row budget. When no bucket is configured, the endpoint rejects image exports with a message explaining that they must run in the background.

Shared workbook generation

Workbook generation has moved from the Celery task into:

superset/dashboards/excel_export/workbook.py

Both execution paths now use the same workbook builder. The Celery task remains responsible only for task execution, storage upload, email delivery, and async-specific error handling.

Each query context is resolved once. The sizing step returns an InlineExportPlan containing the resolved contexts, and the workbook builder executes those exact contexts.

This matters when EXCEL_EXPORT_QUERY_CONTEXT_BUILDER points to an external service: resolving the context twice would add unnecessary cost and could allow one set of queries to be measured while a different set is executed.

Skipped charts

An “Export Summary” worksheet is now added whenever any chart is skipped, rather than only when every chart is skipped.

This keeps the skipped-chart information inside the workbook regardless of how the file is delivered. It is particularly important for the synchronous path, where there is no email containing that information.

The summary-sheet behavior matches the implementation in #43805.

Concurrency and cleanup

Both execution paths use the existing per-user and per-dashboard distributed lock.

The synchronous path releases the lock and deletes its temporary file in a finally block, whether the request succeeds or fails.

This change does not migrate Excel exports to GTF or introduce task_key deduplication. #43407 applies to asynchronous chart-data queries, not dashboard XLSX exports.

Guest and embedded sessions

Guest, embedded, anonymous, and no-email sessions remain blocked on both paths.

The synchronous path does not bypass the existing restriction. A regression test covers a guest token that grants access to the dashboard and confirms that the export is still rejected.

Guest export support remains part of #43805.

Relationship to #43805

#43805 replaces EXCEL_EXPORT_S3_BUCKET with the pluggable EXPORT_STORAGE configuration.

The storage check introduced here is isolated in:

superset/dashboards/excel_export/storage.py

After #43805 lands, the helper can be updated to check for both an EXPORT_STORAGE bucket and backend.

Rebase conflicts are expected in three areas also changed by #43805:

  • the export_xlsx endpoint;
  • the task’s upload logic;
  • the frontend onExportXlsx handler.

The summary-sheet change is intentionally written to match #43805.

API behavior

POST /api/v1/dashboard/<id>/export_xlsx/ now returns one of two successful responses:

  • 200 with the generated .xlsx file when synchronous export is used;
  • 202 with a job ID when the export is queued.

The endpoint no longer returns 501 solely because EXCEL_EXPORT_S3_BUCKET is not configured. Both successful response types are documented in OpenAPI.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

To capture on a deployment without EXCEL_EXPORT_S3_BUCKET configured:

Before

Download → Export Data to Excel → error toast: “Excel export is not configured on this server.”

No file is downloaded.

After

Download → Export Data to Excel → the item displays “Preparing export…” and is disabled while the request runs → the workbook downloads → a “Dashboard data exported to Excel” toast appears.

TESTING INSTRUCTIONS

Automated

pytest tests/unit_tests/tasks/test_export_dashboard_excel.py tests/unit_tests/dashboards/

218 tests.

pytest tests/integration_tests/dashboards/api_tests.py -k export_xlsx

21 tests covering:

  • configured storage preserving the asynchronous 202 response;
  • unconfigured storage returning a synchronous 200 XLSX response;
  • both paths receiving the same dashboard, filter state, mode, and user;
  • the workbook executing the exact query contexts measured by the budget;
  • over-budget and indeterminate-budget refusals;
  • mode=images being rejected without storage;
  • lock release after synchronous success and failure;
  • temporary-file cleanup after success and failure;
  • concurrent exports being rejected by the existing lock;
  • guest sessions remaining blocked;
  • existing dashboard access checks.
npm run test -- DownloadMenuItems.test.tsx

21 tests.

Manual

With no EXCEL_EXPORT_S3_BUCKET configured:

  1. Open a dashboard with a few charts and apply a native filter.
  2. Select Download → Export Data to Excel.
  3. Confirm that the workbook downloads directly, contains one worksheet per chart, and reflects the active filter.
  4. Enable the webdriver screenshot flags and confirm that Export Images to Excel is rejected with a message explaining that EXCEL_EXPORT_S3_BUCKET is required.
  5. Set EXCEL_EXPORT_SYNC_MAX_ROWS = 10 and retry the data export. Confirm that it is rejected with an actionable 400 response before any query runs.
  6. Add a chart without a saved query_context whose visualization type is outside the rebuild allowlist, such as mixed_timeseries. Confirm that the workbook contains an “Export Summary” worksheet naming the skipped chart.

Then configure EXCEL_EXPORT_S3_BUCKET, start the worker and SMTP service, and confirm that the existing asynchronous path is unchanged:

  • the endpoint returns 202;
  • the UI displays “You’ll receive an email when it’s ready”;
  • the download link arrives by email.

ADDITIONAL INFORMATION

EnxDev and others added 2 commits September 9, 2026 12:06
…nfigured

"Export Data to Excel" was only usable where EXCEL_EXPORT_S3_BUCKET was set:
everywhere else the menu item rendered, the endpoint answered 501, and the
click produced nothing but an error toast.

The endpoint now picks its execution path from that same config rather than
refusing. With a bucket it queues the export and answers 202 with a job id,
unchanged. Without one it builds the workbook during the request and returns
it as the response, so the browser downloads the file directly -- no worker,
bucket or email required.

An export served this way has to finish inside one request, so its size is
settled before any query runs: the new EXCEL_EXPORT_SYNC_MAX_ROWS (100,000)
caps the combined row_limit of every query the export would run, and an export
over that total -- or one where any query has no finite limit -- is refused with
a 400 naming the bucket as the fix, rather than being started and left to hit
the request timeout.

Both paths build the same workbook from the same code: the builder moves out of
the Celery task into superset.dashboards.excel_export.workbook, leaving the task
to own only queueing, upload, email and its own error handling. Both acquire the
same per-user+dashboard lock; the inline path releases it, and deletes its temp
file, however the request ends.

Guest, embedded, anonymous and no-email sessions stay blocked on both paths --
guest support is handled separately in #43805 -- and are covered by a regression
test using a guest token that does grant access to the dashboard.

The storage check is isolated in a single helper so it can be repointed at
EXPORT_STORAGE when #43805 lands.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Follow-up to the inline Excel export, addressing three gaps in it:

An image export draws every chart through the headless webdriver, one browser
session at a time. No row budget bounds that, so serving it inline was exactly
the gateway timeout the budget exists to prevent; without export storage it is
now refused with a message saying image exports run in the background.

The skipped-charts list moves into the workbook, on an "Export Summary" sheet
whenever any chart is skipped rather than only when every chart is. The list
then travels with the file however it is delivered, which is the only way an
export served as a download can report it -- and matches the sheet #43805 adds.

Query contexts are resolved once. The row budget already had to resolve them to
size the export, and the builder resolved them again to run it: with
EXCEL_EXPORT_QUERY_CONTEXT_BUILDER pointed at a service, that is both a doubled
cost and a real hazard, since one set of queries could be measured and a
different set run. The budget now returns an InlineExportPlan carrying what it
resolved, and the builder runs those contexts as-is.

The export action also reports progress: while a request is in flight both
Excel actions are disabled and the one clicked reads "Preparing export…",
restored when the file downloads, the queued message arrives, or it fails. The
server's lock prevents duplicate work but told the user nothing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@bito-code-review

bito-code-review Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #06a661

Actionable Suggestions - 0
Additional Suggestions - 5
  • superset/dashboards/api.py - 2
    • Wasted work on locked path · Line 1855-1855
      `plan_inline_export` resolves every chart's query context (documented as expensive and non-deterministic in `sync_budget.py`), but it runs before the per-user+dashboard lock at line 1874. A duplicate concurrent export that will be refused with 202 still pays that cost. Consider computing the plan after acquiring the lock, releasing it on a row-budget refusal.
    • Inline export wrongly gated · Line 1890-1892
      The new inline path (`_export_xlsx_inline`) returns the workbook as the response body and never emails, but the guard at line 1828 (whose comment says "Email delivery is the only result channel") still rejects users without an email address and guest users with a 400. Move that guard into the queued branch so the inline data export works for them.
  • tests/unit_tests/dashboards/test_excel_export_storage.py - 1
    • Incorrect fixture type annotation · Line 33-33
      The `app` fixture in `tests/unit_tests/conftest.py` yields a `SupersetApp`, not a `pytest.FixtureRequest`. Annotating it as `pytest.FixtureRequest` is misleading and defeats static type checking. Use `app: SupersetApp` (import from `superset.app`).
  • tests/unit_tests/dashboards/test_excel_export_workbook.py - 1
    • Unused helper parameter · Line 76-76
      `_build` accepts `charts` but never uses it — the chart list comes from the mocked `get_charts_in_layout_order`. All three call sites pass `[chart]` that is silently discarded. Drop the parameter and the argument to avoid a misleading signature.
  • tests/unit_tests/dashboards/test_excel_export_sync_budget.py - 1
    • Weak per-chart assertion · Line 168-168
      The test name promises each chart is resolved exactly once, but `resolve.call_count == 2` only checks the total. It would still pass if chart 10 were resolved twice and chart 20 zero times, so a regression in `plan_inline_export`'s per-chart dedup would go undetected. Record resolved chart ids via a `side_effect` and assert each appears once.
Review Details
  • Files reviewed - 14 · Commit Range: f64b45f..3108f41
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadMenuItems.test.tsx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx
    • superset/config.py
    • superset/dashboards/api.py
    • superset/dashboards/excel_export/storage.py
    • superset/dashboards/excel_export/sync_budget.py
    • superset/dashboards/excel_export/workbook.py
    • superset/tasks/export_dashboard_excel.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/dashboards/test_excel_export_storage.py
    • tests/unit_tests/dashboards/test_excel_export_sync_budget.py
    • tests/unit_tests/dashboards/test_excel_export_workbook.py
    • tests/unit_tests/tasks/test_export_dashboard_excel.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit c3428fa
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ab9862033abe600081cef83
😎 Deploy Preview https://deploy-preview-44082--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 api Related to the REST API doc Namespace | Anything related to documentation labels Sep 9, 2026
@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.37306% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.19%. Comparing base (c54a331) to head (c3428fa).

Files with missing lines Patch % Lines
superset/dashboards/excel_export/sync_budget.py 93.10% 4 Missing and 4 partials ⚠️
superset/dashboards/api.py 89.65% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44082      +/-   ##
==========================================
+ Coverage   81.17%   81.19%   +0.01%     
==========================================
  Files        2965     2968       +3     
  Lines      179095   179309     +214     
  Branches    41528    41563      +35     
==========================================
+ Hits       145388   145589     +201     
- Misses      31003    31010       +7     
- Partials     2704     2710       +6     
Flag Coverage Δ
hive 36.74% <29.57%> (-0.01%) ⬇️
javascript 76.59% <100.00%> (+<0.01%) ⬆️
mysql 56.06% <57.46%> (+0.16%) ⬆️
postgres 56.07% <57.46%> (+0.16%) ⬆️
presto 38.64% <29.57%> (-0.01%) ⬇️
python 85.46% <96.05%> (+0.01%) ⬆️
sqlite 55.79% <57.46%> (+0.17%) ⬆️
unit 77.75% <84.50%> (-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.

@EnxDev
EnxDev requested a review from sadpandajoe September 9, 2026 16:12
@bito-code-review

bito-code-review Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8d6be8

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/dashboards/excel_export/sync_budget.py - 1
    • row_limit 0 mis-budgeted · Line 54-54
      `or` treats `row_limit: 0` as falsy and substitutes `ROW_LIMIT`, but in Superset `0` means unlimited (`charts/schemas.py` "0=disabled"; `models/helpers.py` only applies `.limit()` when truthy). An unbounded chart is then budgeted as finite 50000, so `fits_row_budget` may approve a sync export that actually returns far more rows. Use an explicit `is None` fallback so `0` stays unbounded.
Review Details
  • Files reviewed - 14 · Commit Range: 3108f41..9dd0c3b
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadMenuItems.test.tsx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx
    • superset/config.py
    • superset/dashboards/api.py
    • superset/dashboards/excel_export/storage.py
    • superset/dashboards/excel_export/workbook.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/dashboards/test_excel_export_storage.py
    • tests/unit_tests/dashboards/test_excel_export_sync_budget.py
    • tests/unit_tests/dashboards/test_excel_export_workbook.py
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset/dashboards/excel_export/sync_budget.py
    • superset/tasks/export_dashboard_excel.py
    • tests/unit_tests/tasks/test_export_dashboard_excel.py
  • Files skipped - 2
    • docs/static/resources/openapi.json - Reason: Filter setting
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@alexandrusoare alexandrusoare 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.

Approved with one nit

Comment thread superset/dashboards/api.py Resolved
@bito-code-review

bito-code-review Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #12d874

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/dashboards/api.py - 1
    • Conditional 304 on download · Line 1943-1951
      `send_file` defaults to `conditional=True`/`etag=True` (werkzeug 3.1). A client/proxy sending `If-None-Match`/`If-Modified-Since` can receive a 304 and reuse a cached copy instead of the freshly generated export. Since this endpoint builds a new workbook per request, pass `conditional=False` to guarantee delivery.
Review Details
  • Files reviewed - 3 · Commit Range: 9dd0c3b..51cb87d
    • superset/dashboards/excel_export/sync_budget.py
    • tests/integration_tests/dashboards/api_tests.py
    • superset/dashboards/api.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@EnxDev
EnxDev requested a review from sadpandajoe September 10, 2026 16:20
@bito-code-review

bito-code-review Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e4dc54

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset/dashboards/excel_export/sync_budget.py - 1
    • Row budget underestimation · Line 63-70
      The `not query.get("is_timeseries")` guard is ineffective for rebuilt query contexts: `build_query_context_from_form_data` never sets `is_timeseries` (verified in `form_data_query_context.py`). A time-series `big_number_total` with a time grain has `columns == []` and metrics, so it is estimated as 1 row but returns one row per time bucket, underestimating `requested_rows` and letting oversized exports pass the sync budget. Consider gating on `granularity`/`time_grain_sqla`.
  • superset/views/base.py - 1
    • Reuse existing storage helper · Line 559-561
      This duplicates the exact check already encapsulated in `is_export_storage_configured()` (`superset/dashboards/excel_export/storage.py`), which `superset/dashboards/api.py:1789` uses for the same storage decision. Reuse that helper so the frontend capability flag and the backend delivery path cannot diverge if the check changes.
  • tests/unit_tests/views/test_bootstrap_auth.py - 1
    • Fragile cache-key test coupling · Line 43-59
      `cached_common_bootstrap_data` is memoized on `(user_id, locale)` (base.py:547), not on `EXCEL_EXPORT_S3_BUCKET`. The distinct `user_id`s (101/102) are what prevent the two parametrized cases from returning a stale cached payload. This is fragile: a future case reusing a `user_id` would silently assert against a cached value. Consider clearing the cache per case instead.
Review Details
  • Files reviewed - 7 · Commit Range: 51cb87d..c800103
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadMenuItems.test.tsx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx
    • superset/dashboards/excel_export/sync_budget.py
    • superset/views/base.py
    • tests/unit_tests/dashboards/test_excel_export_sync_budget.py
    • tests/unit_tests/views/test_bootstrap_auth.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/views/base.py Resolved
The queued task kept its own bucket and backend check, so it could drift
from the predicate the API uses to pick the queued path. Call
is_export_storage_configured() from the task too, and drop the docstring
reference to the removed 501.

Add a test that a guest token revoked for its embedded dashboard gets no
direct download.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@EnxDev EnxDev removed the hold:testing! On hold for testing label Sep 23, 2026
The direct-download budget undercounted two kinds of query:

- A query with an empty columns list but a legacy groupby was counted as
  one aggregate row, though QueryObject promotes groupby into columns.
- Post-processing such as resample or prophet can return more rows than
  row_limit. Only steps known not to add rows keep the query bounded;
  anything else, including operator-registered operations, requires the
  background path.

Regenerate messages.pot for the new export strings, and make the revoked
guest token test assert the identity instead of a status code that
depends on the Public role.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Sep 23, 2026
@bito-code-review

bito-code-review Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #949e01

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/dashboards/excel_export/sync_budget.py - 1
    • pivot margins add rows · Line 42-42
      `pivot` is whitelisted as row-preserving, but `pivot()` with `marginal_distributions=True` appends an "All" margin row (pivot.py:328-337), so the result can exceed the input row count. This breaks the `_ROW_PRESERVING_OPERATIONS` contract ("at most as many rows as they receive") and can make `_finite_row_limit` understate the true row budget for a pivot chart with margins.
  • tests/integration_tests/dashboards/api_tests.py - 1
    • Vacuous mock assertion · Line 4561-4564
      `assert not any(isinstance(call.args[5], GuestUser) ...)` passes vacuously when `build_workbook` is never called (empty `call_args_list` → `any()` is False). If the export is refused with 403/400, the test still passes and misses the regression. Add `mock_build.assert_called()` (or assert `call_args_list` non-empty) so the test confirms the export actually ran as anonymous.
Review Details
  • Files reviewed - 7 · Commit Range: be6f085..78e833e
    • superset/tasks/export_dashboard_excel.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/tasks/test_export_dashboard_excel.py
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset/dashboards/excel_export/sync_budget.py
    • superset/translations/messages.pot
    • tests/unit_tests/dashboards/test_excel_export_sync_budget.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

EnxDev and others added 2 commits September 24, 2026 10:00
… admin

The frontend shows 4xx messages from export_xlsx as-is, so the row-budget
and image-mode refusals reach end users. Wrap both in gettext and ask the
user to contact an administrator instead of naming EXPORT_STORAGE, which
only an operator can set.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 24, 2026
…ownload

A pivot table with a non-additive metric always sends grouping_sets, even
with every totals toggle off, and those queries run without a LIMIT. The
direct download treated one such chart as a reason to refuse the whole
dashboard with advice to lower row limits, which could not help.

Planning now leaves any chart without a known row bound out of the
download and lists it on the Export Summary sheet under its own reason,
so the rest of the dashboard still downloads and the 400 only covers a
real over-budget total. A chart whose context fails to resolve is listed
as an export error, matching the queued path. The empty-dashboard
refusal is translated as well.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #ba6917

Actionable Suggestions - 1
  • tests/unit_tests/dashboards/test_excel_export_workbook.py - 1
Additional Suggestions - 2
  • tests/unit_tests/dashboards/test_excel_export_email.py - 1
    • Missing test docstring · Line 116-118
      The new test `test_errored_groups_explains_unbounded_charts_in_order` documents intent via inline comments only. BITO.md rule 12148 requires every newly added test function to include a docstring and explicitly states inline comments alone are not a substitute (rule 12490 likewise). Convert the comment at lines 117-118 into a docstring as the first statement of the function body.
  • tests/integration_tests/dashboards/api_tests.py - 1
    • Magic string reason key · Line 4299-4299
      `"unbounded-query"` is a magic string duplicating the `email.ERROR_UNBOUNDED` constant (`superset/dashboards/excel_export/email.py:49`). The sibling unit test uses the constant; if the reason key ever changes, this assertion silently compares against a stale literal. Import `email` and reference `email.ERROR_UNBOUNDED`.
Review Details
  • Files reviewed - 11 · Commit Range: 78e833e..ee74ea0
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadMenuItems.test.tsx
    • superset/dashboards/api.py
    • superset/translations/messages.pot
    • tests/integration_tests/dashboards/api_tests.py
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset/dashboards/excel_export/email.py
    • superset/dashboards/excel_export/sync_budget.py
    • superset/dashboards/excel_export/workbook.py
    • tests/unit_tests/dashboards/test_excel_export_email.py
    • tests/unit_tests/dashboards/test_excel_export_sync_budget.py
    • tests/unit_tests/dashboards/test_excel_export_workbook.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

]


def test_skipped_charts_are_listed_by_reason_without_running(

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.

Missing test docstring

New test functions need a docstring per repo rule (BITO.md adaptive rule 12148): docstrings document test intent and are enforced by linting, and an inline comment alone does not satisfy the rule. Add a short docstring above the existing comment in test_skipped_charts_are_listed_by_reason_without_running; no behavior change.

Code Review Run #ba6917


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

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.

Fixed in 8081c98. Every test this PR adds now has a docstring, not only this one, so the new test files stay consistent.

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.

The suggestion to add a docstring to the test function is correct and follows the repository's linting requirements. Applying this change improves the code by documenting the test's intent, as requested by the reviewer.

tests/unit_tests/dashboards/test_excel_export_workbook.py

def test_skipped_charts_are_listed_by_reason_without_running(
    mocks: dict[str, Any], workbook_path: str
) -> None:
    """Test that skipped charts are listed by reason without running."""
    # Skipped charts are listed by reason without running.

@gabotorresruiz gabotorresruiz 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.

Thanks Enzo, this came together really well after the rebase. I checked the extraction carefully since the async path now runs through build_workbook: every helper moved into workbook.py is identical to what the task had (resolve_query_context order, the dashboardId/slice_id stamping, the summary sheet, the running marker and the token-checked lock release in the task), and in async mode build_workbook resolves every chart exactly as before. I ran the unit suites (tests/unit_tests/tasks + tests/unit_tests/dashboards, 326 passed), the export_xlsx integration tests (33 passed), check_pot_drift.py, and the DownloadMenuItems/Header jest files (92 passed) on the head, and CI is green.

One request before merging, not on the code: the PR body still describes the world before #43805 (EXCEL_EXPORT_S3_BUCKET, the 501, and "guest, embedded, anonymous sessions remain blocked on both paths" with a test that "confirms the export is still rejected"). On this branch test_export_xlsx_sync_serves_guest_sessions asserts a GuestUser gets the 200 workbook, and the docs in this PR say the same. Since the body becomes the squash commit message, could you refresh the summary (guest sessions get the direct download too, EXPORT_STORAGE wording, drop the pre-rebase "Relationship to #43805" section) and the test counts (I count 326 / 33 / 39)?

A few small inline notes below, none blocking. LGTM.

Comment thread superset/dashboards/api.py Resolved
Comment thread superset/dashboards/api.py Resolved
EnxDev and others added 2 commits September 24, 2026 16:16
…al storage

When leaving out the charts that can't be sized before they run means no
chart is left, the direct download returned a workbook holding only the
summary sheet while the UI reported success. It now answers 400 and asks
the user to contact an administrator, since the background export can run
those charts. Charts that no path can export still get the workbook, whose
summary sheet explains how to fix them.

A bucket without a backend, or the reverse, quietly selects the direct
download. Log one warning per process naming the missing key, so the
misconfiguration shows up in the logs.

The direct download also uses the no-store cache policy of the download
from storage. New tests get docstrings, and the integration test uses the
ERROR_UNBOUNDED constant instead of its literal value.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bito-code-review

bito-code-review Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8194cf

Actionable Suggestions - 0
Additional Suggestions - 5
  • tests/integration_tests/dashboards/api_tests.py - 2
    • Missing return type hint · Line 4272-4274
      New test method `test_export_xlsx_sync_refused_when_only_unbounded_charts_remain` lacks an explicit `-> None` return annotation. The repo's learned rule 7819 requires return type hints on all methods including tests, and the sibling `test_export_xlsx_sync_refused_when_over_the_row_budget` follows the same convention gap, so adding it here keeps the new code consistent with the mandate.
    • Duplicated refusal-test scaffold · Line 4285-4299
      Lines 4285-4299 duplicate the scaffold of `test_export_xlsx_sync_refused_when_over_the_row_budget` (login, `Dashboard` lookup by slug `world_health`, identical POST body, and the same `mock_acquire`/`mock_release`/`mock_build` assertions). Extracting a shared helper would keep the two refusal tests from diverging when the endpoint contract changes.
  • superset/dashboards/excel_export/storage.py - 1
    • Stale cached warning state · Line 53-54
      `_warn_partial_storage` is memoized with `functools.cache`, so the warning fires once per process per missing key. If an operator fixes `EXPORT_STORAGE` (or breaks it) while the process runs, the stale cached state is never re-reported. The docstring says the check runs on every page load, but the warning does not. If once-per-process is intentional, consider keying the cache on the config object so a config change is re-reported.
  • tests/unit_tests/dashboards/test_excel_export_sync_budget.py - 2
    • Missing row-total assertion · Line 425-425
      This test's name and docstring promise that a grouping-sets-only dashboard "has nothing to download directly", but it never asserts `plan.requested_rows == 0` (compare `test_plan_skips_the_whole_chart_when_one_of_its_queries_is_unbounded`, line 410). If `plan_inline_export` started charging unbounded charts, `fits_row_budget` and `needs_background_export` could still pass here. Assert the row total too. ([BITO.md adaptive rule 6262])
    • Magic number duplicates config default · Line 460-460
      `max_rows=100_000` hardcodes the dashboard's default `EXCEL_EXPORT_SYNC_MAX_ROWS` as a bare literal. The autouse `restore_config` fixture (lines 77-84) already treats the config value as shared module state, so if the default changes this test silently diverges from production. Derive it from `current_app.config` like the other tests do.
Review Details
  • Files reviewed - 10 · Commit Range: ee74ea0..8081c98
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset/dashboards/api.py
    • superset/dashboards/excel_export/storage.py
    • superset/dashboards/excel_export/sync_budget.py
    • superset/translations/messages.pot
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/dashboards/test_excel_export_email.py
    • tests/unit_tests/dashboards/test_excel_export_storage.py
    • tests/unit_tests/dashboards/test_excel_export_sync_budget.py
    • tests/unit_tests/dashboards/test_excel_export_workbook.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@villebro villebro left a comment

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.

One comment for your consideration, other than that LGTM

Comment thread superset/dashboards/api.py Outdated
)
# Keep the request guards and two delivery paths together.
# Resolve the path once so its checks and delivery cannot diverge.
queued = is_export_storage_configured()

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.

It seems we're only checking that the storage flag is configured, but shouldn't we also make sure Celery is available on the backend?

@EnxDev EnxDev Sep 26, 2026 •

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.

Good catch. With CELERY_CONFIG = None, we could still queue the export even though no worker was running. I changed the check so background export now requires both storage and Celery; otherwise it falls back to direct download. The bootstrap flag uses the same check, and tests cover both cases.

I didn't add a live worker check because control.ping() would add a broker round trip/timeout on every export and page load, and it still wouldn't guarantee a worker is consuming. This matches how SQL Lab async, thumbnails, and reports behave today. I also updated the docs and UPDATING.

@rusackas rusackas left a comment

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.

Heya @EnxDev, this has clearly been through a lot of rounds already, the row-budget edge cases sadpandajoe found (grouping sets, KPI aggregates, string-coerced row limits) and gabotorresruiz's cache-control/warning nits all check out against the current code.

One thing before this merges, though. onExportXlsx's catch handler used to only special-case status === 501; it's now widened to any 4xx and passes the raw server message straight into addDangerToast. That's fine for this PR's own new 400s, they're all plain gettext() strings, but the pre-existing ValidationError path in export_xlsx returns message=error.messages, a dict, not a string, and addDangerToast renders through Interweave which expects one. Narrow to trigger from the normal UI, but worth guarding.

A complete EXPORT_STORAGE with CELERY_CONFIG = None queued exports on a
broker nobody runs. Background exports now also require CELERY_CONFIG,
falling back to the direct download and logging a warning once otherwise.
The bootstrap flag follows the same check so image export stays hidden.

The export error toast only shows a 4xx message when it is a string: a
schema ValidationError returns a dict of field errors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@EnxDev
EnxDev requested a review from rusackas September 26, 2026 08:09
@bito-code-review

bito-code-review Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #19a74b

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/integration_tests/dashboards/api_tests.py - 1
    • Duplicated test body · Line 3771-3793
      This new test body (lines 3783-3793) is a near-verbatim copy of `test_export_xlsx_bucket_without_backend_downloads_directly` (3759-3769); only the `with_config` payload differs (`CELERY_CONFIG: None`). Consider parameterizing the shared login/POST/assert sequence so the two direct-download branches stay in sync.
Review Details
  • Files reviewed - 10 · Commit Range: 8081c98..9d482b7
    • docs/docs/using-superset/exporting-dashboard-data.mdx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadMenuItems.test.tsx
    • superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx
    • superset/config.py
    • superset/dashboards/api.py
    • superset/dashboards/excel_export/storage.py
    • superset/views/base.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/dashboards/test_excel_export_storage.py
    • tests/unit_tests/views/test_bootstrap_auth.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

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.

Confirmed, this is fixed. onExportXlsx's catch handler now guards with typeof message === 'string' before passing it to addDangerToast, with a regression test covering the dict-shaped ValidationError case that would've broken it. That was the only thing I was waiting on. LGTM

…llback

# Conflicts:
#	superset/translations/messages.pot
@EnxDev
EnxDev merged commit 891c2ed into master Sep 27, 2026
79 checks passed
@EnxDev
EnxDev deleted the enxdev/feat/dashboard-excel-export-sync-fallback branch September 27, 2026 21:48
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

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

Labels

api Related to the REST API doc Namespace | Anything related to documentation i18n Namespace | Anything related to localization size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants