Skip to content

fix(export): fix double app-root prefix in chart/drill-detail export URLs#39710

Merged
eschutho merged 1 commit into
masterfrom
subdirectory-export
May 13, 2026
Merged

fix(export): fix double app-root prefix in chart/drill-detail export URLs#39710
eschutho merged 1 commit into
masterfrom
subdirectory-export

Conversation

@eschutho
Copy link
Copy Markdown
Member

SUMMARY

When Superset is deployed as a subdirectory (e.g. SUPERSET_APP_ROOT=/analytics), export URLs were getting the app root prepended twice, resulting in broken URLs like:

http://localhost:8088/analytics/analytics/api/v1/dataset/export/?q=!(26)

Root cause: SupersetClient.postForm(endpoint) calls getUrl({ endpoint }) internally, which prepends this.appRoot. Any caller that also called ensureAppRoot() on the URL before passing it to SupersetClient would produce a double-prefixed URL.

Fix: Build export URLs without the app root prefix and apply ensureAppRoot only where the consumer is native fetch (not SupersetClient):

  • exportChart (exploreUtils/index.ts): URL is now built without appRoot. For the streaming path (onStartStreamingExportuseStreamingExport → native fetch), ensureAppRoot is applied before passing. For the SupersetClient.postForm fallback, the raw URL is passed and SupersetClient adds the prefix.
  • DrillDetailPane: Removed ensureAppRoot() wrapper around SupersetClient.postForm('/api/v1/chart/data', ...).
  • chartAction: Removed ensureAppRoot() wrapper around SupersetClient.postForm('/sqllab/', ...).

Also adds includeAppRoot?: boolean param to getExploreUrl so the legacy API path can build an unprefixed relative URL for the postForm fallback.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — URL construction fix, no visual change.

TESTING INSTRUCTIONS

  1. Configure SUPERSET_APP_ROOT to a subdirectory, e.g. /analytics.
  2. Log in to Superset.
  3. Export a dashboard, chart, dataset, or database connection — should succeed without double-prefix in the URL.
  4. From the Explore view, export a chart as CSV or XLSX — should succeed.
  5. From a dashboard, use the drill-detail export — should succeed.
  6. Run the updated Jest tests: npm run test -- exportChart.test.ts

ADDITIONAL INFORMATION

  • Has associated issue: Fixes sc-104713
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 28, 2026

Code Review Agent Run #7c1054

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 86fe4fc..86fe4fc
    • superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
    • superset-frontend/src/components/Chart/chartAction.ts
    • superset-frontend/src/explore/exploreUtils/exportChart.test.ts
    • superset-frontend/src/explore/exploreUtils/index.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

@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:export Related to exporting charts labels Apr 28, 2026
@eschutho eschutho marked this pull request as draft April 28, 2026 20:06
@eschutho eschutho marked this pull request as ready for review May 8, 2026 18:19
@dosubot dosubot Bot added the explore Namespace | Anything related to Explore label May 8, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 8, 2026

Deploy Preview for superset-docs-preview ready!

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

…URLs

When Superset is deployed as a subdirectory (SUPERSET_APP_ROOT), export
URLs were getting the app root applied twice. SupersetClient.postForm()
adds the appRoot internally via getUrl(), so callers must not pre-apply
ensureAppRoot() before passing an endpoint to any SupersetClient method.

Fix:
- exportChart: build URL without appRoot; apply ensureAppRoot only for
  the streaming path (native fetch), leave raw for postForm path
- DrillDetailPane: remove ensureAppRoot() before SupersetClient.postForm()
- chartAction: remove ensureAppRoot() before SupersetClient.postForm()
- Add getExploreUrl includeAppRoot param to support building unprefixed
  legacy API URLs for the non-streaming fallback
- Add regression test: postForm must receive unprefixed URL even when
  SUPERSET_APP_ROOT is configured

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eschutho eschutho force-pushed the subdirectory-export branch from ece1fb0 to 7cac85f Compare May 8, 2026 22:50
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.82%. Comparing base (547660d) to head (7cac85f).

Files with missing lines Patch % Lines
...erset-frontend/src/components/Chart/chartAction.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39710      +/-   ##
==========================================
- Coverage   63.86%   63.82%   -0.04%     
==========================================
  Files        2584     2589       +5     
  Lines      136678   137807    +1129     
  Branches    31515    31923     +408     
==========================================
+ Hits        87290    87962     +672     
- Misses      47872    48329     +457     
  Partials     1516     1516              
Flag Coverage Δ
javascript 66.52% <83.33%> (-0.11%) ⬇️

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.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 9, 2026

Code Review Agent Run #9190c0

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 7cac85f..7cac85f
    • superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
    • superset-frontend/src/components/Chart/chartAction.ts
    • superset-frontend/src/explore/exploreUtils/exportChart.test.ts
    • superset-frontend/src/explore/exploreUtils/index.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

Copy link
Copy Markdown
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

LGTM!

@eschutho eschutho merged commit 958d4aa into master May 13, 2026
73 checks passed
@eschutho eschutho deleted the subdirectory-export branch May 13, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend explore Namespace | Anything related to Explore size/M viz:charts:export Related to exporting charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants