Skip to content

fix(embedded): add guest token to streaming exports#40712

Merged
richardfogaca merged 4 commits into
apache:masterfrom
richardfogaca:rch-118-csv-export-with-row-limit-issue
Jun 5, 2026
Merged

fix(embedded): add guest token to streaming exports#40712
richardfogaca merged 4 commits into
apache:masterfrom
richardfogaca:rch-118-csv-export-with-row-limit-issue

Conversation

@richardfogaca
Copy link
Copy Markdown
Contributor

SUMMARY

This fixes embedded dashboard streaming CSV exports for table-like charts whose row limit enters the large-export path.

Previously, the streaming export hook built a native fetch form request with chart export fields but did not include the active embedded guest token. Embedded users could load the dashboard, but the CSV export POST reached the chart data API without guest-auth material and failed before returning the CSV.

The change adds the configured guest token to the streaming export form body when one is present. Backend guest authentication remains the authority; the frontend only transports the existing token on the native streaming request path. The regression test covers the token-bearing case while existing hook coverage keeps the no-token and adjacent streaming behaviors intact.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A - no public screenshot or recording is attached to this PR. The verified behavior is described in the testing instructions below.

TESTING INSTRUCTIONS

  • Live browser validation in a local Superset compose runtime: opened an embedded dashboard host with a guest token, used the chart More Options → Download → Export to .CSV flow for a table chart with row_limit=100000, and observed the CSV Export modal reach the successful state with a Download button. Regression condition: the previous export failure/401 state did not recur.
  • Live API/network validation in the same local runtime: inspected the chart export POST to /api/v1/chart/data from that embedded export scenario and observed guest_token and expected_rows=100000 in the submitted form, plus a 200 OK text/csv response with CSV rows. Regression condition: the request no longer omitted embedded auth material or returned the prior unauthorized export failure.
  • Focused regression command: npm run test -- src/components/StreamingExportModal/useStreamingExport.test.ts

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • 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

Reviewer focus: this is intentionally limited to the streaming export request builder and its tests; it should not change backend authorization rules, export thresholds, or provider-specific SQL execution.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3a6fc56
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a2063dcbfc6bf00085a295a
😎 Deploy Preview https://deploy-preview-40712--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.

@richardfogaca richardfogaca marked this pull request as ready for review June 3, 2026 16:31
Copilot AI review requested due to automatic review settings June 3, 2026 16:31
@dosubot dosubot Bot added the embedded label Jun 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

@aminghadersohi aminghadersohi left a comment

Choose a reason for hiding this comment

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

Scans 1–19 (Python): N/A — TypeScript-only PR. TypeScript checks clean. Security checks clean (backend reads req.form.get("guest_token") at security/manager.py:3464 — established mechanism; raise_for_access() applies same RLS/permission checks as all guest requests; expired token yields 401 before stream opens). CI: sharded-jest, lint-frontend, pre-commit, CodeQL all pass. DB test failures are infra-class ("Set up job" step failed); Playwright failures are infra-class ("Build embedded SDK" step failed before any tests ran). Both unrelated to this frontend-only change.

expect(request.body.get('form_data')).toBe(
JSON.stringify({ datasource: '1__table', viz_type: 'table' }),
);
});
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.

NIT: The new test covers the token-present path, but no test (new or existing) explicitly asserts that guest_token is absent from the form body when getGuestToken() returns undefined. beforeEach resets the mock to undefined so all prior tests implicitly run without a token, but none assert the absence. A companion test or a single added assertion (e.g. expect(request.body.get('guest_token')).toBeNull() in an existing chart-export test) would guard against accidental token injection in a future refactor and make the boundary explicit.

@bito-code-review
Copy link
Copy Markdown
Contributor

The reviewer's suggestion to explicitly assert the absence of guest_token in the form body when getGuestToken() returns undefined is a valid improvement. Adding an assertion like expect(request.body.get('guest_token')).toBeNull() in the test suite provides a clear boundary and prevents potential regressions where a token might be accidentally injected in future refactors.

@richardfogaca richardfogaca force-pushed the rch-118-csv-export-with-row-limit-issue branch from 4244b4a to 3a6fc56 Compare June 3, 2026 17:26
@github-actions github-actions Bot removed the embedded label Jun 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.07%. Comparing base (45a6164) to head (019eec3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #40712   +/-   ##
=======================================
  Coverage   64.07%   64.07%           
=======================================
  Files        2664     2664           
  Lines      143831   143834    +3     
  Branches    33084    33085    +1     
=======================================
+ Hits        92160    92168    +8     
+ Misses      50062    50059    -3     
+ Partials     1609     1607    -2     
Flag Coverage Δ
javascript 67.63% <100.00%> (+<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.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jun 3, 2026

Code Review Agent Run #3c0f3b

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/src/components/StreamingExportModal/useStreamingExport.test.ts - 1
Review Details
  • Files reviewed - 2 · Commit Range: 0574900..4c16b96
    • superset-frontend/src/components/StreamingExportModal/useStreamingExport.test.ts
    • superset-frontend/src/components/StreamingExportModal/useStreamingExport.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ 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

@richardfogaca richardfogaca merged commit 601f9c2 into apache:master Jun 5, 2026
63 checks passed
@richardfogaca richardfogaca deleted the rch-118-csv-export-with-row-limit-issue branch June 5, 2026 16:27
sadpandajoe added a commit that referenced this pull request Jun 5, 2026
Resolved conflicts:
- UPDATING.md: kept both — PR #39925 subdirectory-deployment block and
  master's Intl.DurationFormat block are independent "Next" entries.
- superset/translations/messages.pot + 26 .po files: took master's
  baseline (--theirs) and re-extracted via babel_update.sh so PR-introduced
  strings are folded into master's updated catalog.

Inbound master highlights:
- Intl.DurationFormat replaces pretty-ms (#39330)
- Streaming-export guest-token plumbing (#40712)
- ChartRenderer/Chart/DrillByChart converted to function components
- Routine dep bumps (react-map-gl, @ant-design/icons, dayjs, etc.)

Rebuilt superset-ui-core .d.ts via tsc -b so the new createDurationFormatter
locale option is visible to pre-commit type-checking. Verified Slice 8
navigateTo/navigateWithState edits in dashboardState.ts and SupersetClient
routing edits in useStreamingExport.ts survived auto-merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants