Repository navigation
feat(dashboard): download the Excel export directly when no export storage is configured - #44082
Conversation
…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]>
Code Review Agent Run #06a661Actionable Suggestions - 0Additional Suggestions - 5
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
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
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:
|
Code Review Agent Run #8d6be8Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
alexandrusoare
left a comment
There was a problem hiding this comment.
Approved with one nit
Code Review Agent Run #12d874Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #e4dc54Actionable Suggestions - 0Additional Suggestions - 3
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
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]>
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]>
Code Review Agent Run #949e01Actionable Suggestions - 0Additional Suggestions - 2
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
… 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]>
…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]>
There was a problem hiding this comment.
Code Review Agent Run #ba6917
Actionable Suggestions - 1
-
tests/unit_tests/dashboards/test_excel_export_workbook.py - 1
- Missing test docstring · Line 116-116
Additional Suggestions - 2
-
tests/unit_tests/dashboards/test_excel_export_email.py - 1
-
Missing test docstring · Line 116-118The 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
| ] | ||
|
|
||
|
|
||
| def test_skipped_charts_are_listed_by_reason_without_running( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Fixed in 8081c98. Every test this PR adds now has a docstring, not only this one, so the new test files stay consistent.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
…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]>
Code Review Agent Run #8194cfActionable Suggestions - 0Additional Suggestions - 5
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
villebro
left a comment
There was a problem hiding this comment.
One comment for your consideration, other than that LGTM
| ) | ||
| # 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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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]>
Code Review Agent Run #19a74bActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rusackas
left a comment
There was a problem hiding this comment.
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
|
Bito Automatic Review Skipped – PR Already Merged |
SUMMARY
“Export Data to Excel” previously worked only when
EXCEL_EXPORT_S3_BUCKETwas configured. On deployments without a bucket, the menu item was still visible because it is controlled by thecan_exportpermission, but the endpoint returned501and the user received an error toast.The endpoint now selects the execution path based on the existing storage configuration:
202with a job ID.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_ROWSconfiguration value, with a default of100_000, limits the combinedrow_limitof every query the export would execute.The synchronous export is refused with an actionable
400response when:The error explains that
EXCEL_EXPORT_S3_BUCKETmust 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=imagesis 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:
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
InlineExportPlancontaining the resolved contexts, and the workbook builder executes those exact contexts.This matters when
EXCEL_EXPORT_QUERY_CONTEXT_BUILDERpoints 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
finallyblock, whether the request succeeds or fails.This change does not migrate Excel exports to GTF or introduce
task_keydeduplication. #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_BUCKETwith the pluggableEXPORT_STORAGEconfiguration.The storage check introduced here is isolated in:
After #43805 lands, the helper can be updated to check for both an
EXPORT_STORAGEbucket and backend.Rebase conflicts are expected in three areas also changed by #43805:
export_xlsxendpoint;onExportXlsxhandler.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:200with the generated.xlsxfile when synchronous export is used;202with a job ID when the export is queued.The endpoint no longer returns
501solely becauseEXCEL_EXPORT_S3_BUCKETis 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_BUCKETconfigured: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
218 tests.
21 tests covering:
202response;200XLSX response;mode=imagesbeing rejected without storage;21 tests.
Manual
With no
EXCEL_EXPORT_S3_BUCKETconfigured:EXCEL_EXPORT_S3_BUCKETis required.EXCEL_EXPORT_SYNC_MAX_ROWS = 10and retry the data export. Confirm that it is rejected with an actionable400response before any query runs.query_contextwhose visualization type is outside the rebuild allowlist, such asmixed_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:202;ADDITIONAL INFORMATION