You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gabotorresruiz (via GitHub)" <gi...@apache.org> on 2026/08/19 19:15:08 UTC
[PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
gabotorresruiz opened a new pull request, #43340:
URL: https://github.com/apache/superset/pull/43340
### SUMMARY
Targets `fix/excel-export-guest-sessions-and-s3-link-expiry` (#43336), not `master` — it fixes a bug in that PR's guest path and is meant to merge into it so the guard removal and this fix travel together.
#43336 removes the `isinstance(g.user, GuestUser)` → 400 guard so embedded guests can export, but `export_xlsx` still calls `g.user.id` (for the throttle-lock params and the Celery task's `user_id`). `GuestUser` extends `AnonymousUserMixin` and has no `id` attribute, so a guest POST crashes with `AttributeError` → 500 `{"message": "Fatal error"}` before the task is ever enqueued. Verified empirically on a staging deployment carrying #43336's changes: the embedded export button returned exactly that 500; with this fix applied the export goes through.
The fix mirrors `_load_user_from_job_metadata` in `superset/tasks/async_queries.py`:
- The endpoint passes `user_id=get_user_id()` (`None` for guests) plus `guest_token=getattr(g.user, "guest_token", None)`.
- The task reconstructs the guest via `security_manager.get_guest_user_from_token(...)`, so the export runs under the token's RLS rules and resource claims — never under an elevated identity.
- Guests share throttle-lock slot 0 per dashboard, acquired and released with the same key.
### TESTING INSTRUCTIONS
- New unit test `test_guest_export_reconstructs_guest_user_and_shares_lock_slot_zero` covers the guest resolution, the skipped email, and the slot-0 lock release.
- Manual: embed a dashboard, trigger Export Data to Excel as a guest — previously 500, now 202 + pollable download.
### ADDITIONAL INFORMATION
- [x] Has associated issue: fixes the guest path of #43336
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_012HwFSVNUzsZ4xW6D8Y2n95
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867584510
##########
superset/dashboards/excel_export/download_link.py:
##########
@@ -98,23 +99,38 @@ def build_download_url(job_id: UUID) -> str:
def create_download_link(
- job_id: UUID, bucket: str, key: str, expires_at: datetime
+ job_id: UUID, bucket: str, key: str, expires_at: datetime, backend: str
) -> str:
"""Record that ``job_id``'s export succeeded and is downloadable from
``key`` in ``bucket`` until ``expires_at``, and return the download URL
(used in the success email).
+ ``backend`` is the dotted path of the ``ExportStorage`` class that
+ uploaded the file; the download redirect refuses to sign with a different
+ backend (see ``download_xlsx``), failing clearly after a storage migration
+ instead of minting a URL for the wrong provider.
+
``expires_at`` should be a naive datetime in the same timezone convention
``KeyValueEntry.is_expired()`` compares against (naive ``datetime.now()``).
"""
_sweep_and_upsert(
job_id,
- {"status": STATUS_READY, "bucket": bucket, "key": key},
+ {"status": STATUS_READY, "bucket": bucket, "key": key, "backend": backend},
expires_at,
)
return build_download_url(job_id)
+def mark_export_running(job_id: UUID, expires_at: datetime) -> None:
+ """Record that a worker has started executing ``job_id`` (as opposed to
+ still sitting in the queue), so a polling client can wait out broker
+ backlog without racing the task's execution budget, which only starts
+ here. Overwritten by the terminal record; ``expires_at`` is the backstop
+ if the worker dies first.
+ """
+ _sweep_and_upsert(job_id, {"status": STATUS_RUNNING}, expires_at)
Review Comment:
Confirmed and fixed in 2739f7e1fb. I verified it empirically first: write, session remove, fresh read returned None. _sweep_and_upsert is now transaction wrapped, which also makes the ready and error records durable at write time instead of riding the lock release commit in the task's finally. The status integration test now does a session remove with no explicit commit before reading through the API.
##########
superset/dashboards/api.py:
##########
@@ -1795,6 +1801,14 @@ def export_xlsx(self, pk: int) -> WerkzeugResponse:
):
return self.response_404()
+ # The webdriver cannot render under a guest identity: the export would
+ # hold the shared guest lock for its whole budget and produce nothing.
+ # The UI hides the option for guests, but hiding is not enforcement.
+ if payload.get("mode") == "images" and security_manager.is_guest_user():
Review Comment:
Fixed in 2739f7e1fb: the predicate is now get_user_id() is None, covering anonymous requesters as well as guests and matching the UI's gate exactly. Test updated to patch get_user_id.
##########
superset/utils/gcs.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+``ExportStorage`` implementation backed by Google Cloud Storage, for
+deployments where the export bucket is a native GCS bucket rather than S3.
+
+Set ``EXPORT_STORAGE["backend"] = GCSExportStorage()`` in
+``superset_config.py`` (vs ``superset.utils.s3.S3ExportStorage`` for an S3
+bucket). Authentication uses Application Default Credentials (a
+service account key, workload identity, etc.) via the standard
+``google-cloud-storage`` resolution chain -- there is no separate credential
+config here. Signed download URLs from token-only credentials (workload
+identity, GCE metadata, Cloud Run) are routed through the IAM signBlob API,
+which requires ``roles/iam.serviceAccountTokenCreator`` on the service
+account itself.
+"""
+
+from __future__ import annotations
+
+from datetime import timedelta
+from typing import Any
+
+
+def _get_client() -> Any:
+ """Build a GCS client using Application Default Credentials."""
+ # Imported lazily, mirroring superset.utils.s3.S3ExportStorage: importing
+ # this module (which happens at config-load time if EXPORT_STORAGE
+ # is set) should not require google-cloud-storage unless an export
+ # actually runs.
+ try:
+ from google.cloud import storage # pylint: disable=import-outside-toplevel
+ except ImportError as ex:
+ raise ImportError(
+ "google-cloud-storage is required for GCSExportStorage but is not "
+ "installed. Install it with "
+ "`pip install apache-superset[excel-export-gcs]`."
+ ) from ex
+
+ return storage.Client()
+
+
+class GCSExportStorage:
+ """``ExportStorage`` backed by Google Cloud Storage.
+
+ See ``superset.utils.export_storage.ExportStorage`` for the interface this
+ implements.
+ """
+
+ def upload_file(self, local_path: str, bucket: str, key: str) -> None:
+ """
+ Upload a local file to GCS.
+
+ :param local_path: Path to the file on local disk
+ :param bucket: Destination GCS bucket
+ :param key: Destination GCS blob name
+ """
+ _get_client().bucket(bucket).blob(key).upload_from_filename(local_path)
+
+ def generate_download_url(self, bucket: str, key: str, expires_in: int) -> str:
+ """
+ Generate a time-limited signed URL for downloading a GCS object.
+
+ Token-only Application Default Credentials (GKE workload identity, GCE
+ metadata, Cloud Run) carry no private key, so local V4 signing raises.
+ For those, route the signature through the IAM signBlob API by passing
+ ``service_account_email`` and ``access_token``; the service account
+ needs ``roles/iam.serviceAccountTokenCreator`` on itself.
+
+ :param bucket: The GCS bucket
+ :param key: The GCS blob name
+ :param expires_in: URL lifetime in seconds
+ :returns: A v4 signed URL
+ """
+ # pylint: disable=import-outside-toplevel
+ import google.auth
+ from google.auth import credentials as auth_credentials
+ from google.auth.transport import requests as auth_requests
+
+ blob = _get_client().bucket(bucket).blob(key)
+ signing_kwargs: dict[str, Any] = {}
+ credentials, _ = google.auth.default()
Review Comment:
Fixed in 2739f7e1fb: the signing path now calls google.auth.default with an explicit cloud-platform scope, so external account and workload identity credentials can refresh for signBlob.
##########
UPDATING.md:
##########
@@ -274,19 +274,32 @@ Note that a retried query returns partial data with no truncation indicator
(e.g. a filter dropdown may list only a subset of values on tables above the
row cap).
-### Dashboard "Export Data to Excel" requires a Celery worker and S3 bucket
+### Dashboard "Export Data to Excel" requires a Celery worker and a storage bucket
A new dashboard action exports every chart's data to a single multi-sheet
`.xlsx` asynchronously. It is disabled by default and turns on only when
-`EXCEL_EXPORT_S3_BUCKET` is set (the endpoint returns `501` otherwise). It also
-requires a running Celery worker and a configured SMTP transport, since the task
-emails the requesting user a pre-signed download link. New config keys:
-`EXCEL_EXPORT_S3_BUCKET`, `EXCEL_EXPORT_S3_KEY_PREFIX`,
-`EXCEL_EXPORT_LINK_TTL_SECONDS`, `EXCEL_EXPORT_S3_CLIENT_KWARGS`,
+`EXPORT_STORAGE` is configured with both a `bucket` and a `backend` (the
+endpoint returns `501` otherwise) — there is no implicit storage default:
+
+```python
+from superset.utils.s3 import S3ExportStorage # or superset.utils.gcs.GCSExportStorage
+
+EXPORT_STORAGE = {
+ "bucket": "my-export-bucket",
+ "backend": S3ExportStorage(),
+}
+```
+
+It also requires a running Celery worker and a configured SMTP transport, since
Review Comment:
Fixed in 2739f7e1fb: UPDATING.md now documents SMTP as optional, used only to additionally email logged in users, with polling as the delivery path for every session.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5464293462
Thanks Elizabeth! Content-Length added in 5da2b3620a with the shape you suggested: download() now returns (size, chunks) as a small NamedTuple, S3 reads ContentLength off the get_object call it already makes, and GCS does one blob.reload() that doubles as an eager existence check, which also let me drop the first chunk pull trick from the endpoint. Integration test asserts the header. On the nits: agreed the empty object case is unreachable (every export carries at least the summary sheet), and the dashboard title filename is a nice follow up since the job record would need to carry the title; leaving both as is for this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867496789
##########
tests/integration_tests/dashboards/api_tests.py:
##########
@@ -3526,7 +3544,7 @@ def test_export_xlsx_admitted_with_can_export_only(
db.session.commit()
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
- @with_config({"EXCEL_EXPORT_S3_BUCKET": "exports"})
+ @with_config({"EXPORT_STORAGE": {"bucket": "exports", "backend": MagicMock()}})
@patch("superset.dashboards.api.AcquireDistributedLock")
@patch("superset.dashboards.api.export_dashboard_excel")
def test_export_xlsx_admitted_without_email(self, mock_task, mock_acquire):
Review Comment:
This only exercises a logged-in user with an empty email, which still has `g.user.id`; it cannot catch the guest crash or loss of guest-token claims this change fixes. Could this use a real guest-token request and assert the `user_id=None` and guest-token task kwargs, so the API-to-worker handoff is covered?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867585825
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -83,9 +92,27 @@ export const useDownloadMenuItems = (
canExportImage,
} = props;
- const { addDangerToast, addSuccessToast } = useToasts();
+ const { addDangerToast, addSuccessToast, addInfoToast } = useToasts();
const dataMask = useSelector((state: RootState) => state.dataMask);
- const SCREENSHOT_NODE_SELECTOR = ".dashboard";
+ const user = useSelector((state: RootState) => state.user);
+ // Guests and anonymous sessions have no userId; sessions the backend
+ // cannot email get neutral copy and a poll window outliving the task budget.
+ const isGuestSession = !user?.userId;
+ const canReceiveEmail = Boolean(user?.userId && user?.email);
Review Comment:
Fixed in 2739f7e1fb, taking the simplification: one 12 minute poll window for every session, since the email is best effort (SMTP optional, send failures swallowed) and cannot be treated as a fallback. Identity now only selects the toast copy.
##########
tests/integration_tests/dashboards/api_tests.py:
##########
@@ -3526,7 +3544,7 @@ def test_export_xlsx_admitted_with_can_export_only(
db.session.commit()
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
- @with_config({"EXCEL_EXPORT_S3_BUCKET": "exports"})
+ @with_config({"EXPORT_STORAGE": {"bucket": "exports", "backend": MagicMock()}})
@patch("superset.dashboards.api.AcquireDistributedLock")
@patch("superset.dashboards.api.export_dashboard_excel")
def test_export_xlsx_admitted_without_email(self, mock_task, mock_acquire):
Review Comment:
Added in 2739f7e1fb: test_export_xlsx_guest_enqueues_with_token_and_no_user_id asserts the API enqueues user_id None plus the guest token payload and acquires lock slot 0, covering the API to worker handoff.
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -441,6 +453,59 @@ def _handle_export_failure(
logger.exception("Failed to record export failure status for %s", job_id)
+def _resolve_export_storage(
+ dashboard_id: int, job_id: str
+) -> tuple[ExportStorage, str, str]:
+ """The configured storage backend, bucket, and this export's object key.
+
+ The API already rejects the request with 501 when either the bucket or
+ the backend is unset, so reaching this unconfigured normally means
+ EXPORT_STORAGE was cleared after the job was enqueued (or the task
+ was invoked directly, bypassing the API). Fail with a clear message
+ instead of an opaque storage-SDK error.
+ """
+ storage_config = current_app.config["EXPORT_STORAGE"]
+ bucket = storage_config.get("bucket")
+ storage_backend = storage_config.get("backend")
+ if not bucket or storage_backend is None:
+ raise SupersetException(
+ "Excel export is not configured on this server: "
+ "EXPORT_STORAGE needs both a 'bucket' and a 'backend' "
+ "(e.g. superset.utils.s3.S3ExportStorage())."
+ )
+ key_prefix = storage_config.get("key_prefix", "dashboard-exports/")
+ if callable(key_prefix):
+ # A callable prefix is resolved per export, for deployments where it
+ # is only known in task context (e.g. a multi-tenant installation
+ # scoping a shared bucket per tenant).
+ key_prefix = key_prefix()
+ return storage_backend, bucket, f"{key_prefix}{dashboard_id}/{job_id}.xlsx"
+
+
+def _mark_running(job_id: str) -> None:
+ """Tell pollers execution has begun (vs. queued); best-effort, the export
+ must not fail over a status write."""
+ try:
+ expires_at = datetime.now(tz=timezone.utc) + timedelta(
+ seconds=EXPORT_HARD_TIME_LIMIT + 300
+ )
+ mark_export_running(uuid.UUID(job_id), expires_at.replace(tzinfo=None))
+ except Exception: # pylint: disable=broad-except
+ logger.exception("Failed to record running status for %s", job_id)
+
+
+def _resolve_requesting_user(
+ user_id: int | None, guest_token: GuestToken | None
+) -> Any:
+ if user_id is not None:
+ return security_manager.get_user_by_id(user_id)
+ if guest_token:
+ return security_manager.get_guest_user_from_token(guest_token)
Review Comment:
Keeping as is, deliberately: this mirrors superset.tasks.async_queries, which reconstructs the guest from the already validated payload. The access decision is enforced at request time via raise_for_access, guest tokens are short lived stateless JWTs with no server side revocation to consult, and enforcing exp in the worker would fail every legitimately queued export since tokens routinely expire within a normal queue wait. If delayed execution under a stale token is a concern worth addressing, I think it belongs to both consumers together as a follow up rather than this PR.
##########
superset/dashboards/api.py:
##########
@@ -1814,7 +1828,12 @@ def export_xlsx(self, pk: int) -> WerkzeugResponse:
# otherwise) so the guard works across the web server and workers and is
# not a no-op under the default cache. The task releases it when it
# settles; the TTL is the backstop if that release is ever lost.
- lock_params = export_lock_params(g.user.id, dashboard.id)
+ # A guest/embedded requester has no DB-backed user id (GuestUser carries
+ # no ``id`` attribute at all), so all guests share lock slot 0 for the
+ # dashboard; the task reconstructs the guest (with the token's RLS rules
+ # and resource claims) from the token payload passed alongside.
+ user_id = get_user_id()
+ lock_params = export_lock_params(user_id or 0, dashboard.id)
try:
Review Comment:
Real but bounded, and I would defer it: the worst case is a second concurrent export while the first finishes, and the throttle is best effort by design. This base branch's release is an unconditioned delete with no extend primitive, so renewing from the task would be a release plus acquire, which is itself a race. Master already has ownership checked release (compare and delete); the clean fix is lease extension plus owned release when this stack rebases onto master, and I am happy to file that follow up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5346913092
<!-- Bito Reply -->
The flagged issue is correct. In `superset/tasks/export_dashboard_excel.py`, the guest user reconstruction (`security_manager.get_guest_user_from_token(guest_token)`) occurs before the `try`/`finally` block that ensures the distributed lock is released. If this reconstruction fails, the task terminates without releasing the lock, causing subsequent exports for that dashboard to be blocked until the TTL expires.
To resolve this, move the user reconstruction logic inside the `try` block or ensure the lock is released in a `finally` block that covers the entire execution path. Given the current structure, wrapping the user initialization in the `try` block is the most straightforward fix.
**superset/tasks/export_dashboard_excel.py**
```
# ... (previous code)
requested_at = datetime.now(tz=timezone.utc)
try:
if user_id is not None:
user = security_manager.get_user_by_id(user_id)
elif guest_token:
user = security_manager.get_guest_user_from_token(guest_token)
else:
user = None
# ... (rest of the logic)
finally:
# ... (lock release logic)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3866921272
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -16,42 +16,48 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { SyntheticEvent } from "react";
-import { useSelector } from "react-redux";
-import { logging } from "@apache-superset/core/utils";
-import { t } from "@apache-superset/core/translation";
+import { SyntheticEvent } from 'react';
+import { useSelector } from 'react-redux';
+import { logging } from '@apache-superset/core/utils';
+import { t } from '@apache-superset/core/translation';
import {
FeatureFlag,
getClientErrorObject,
isFeatureEnabled,
SupersetClient,
-} from "@superset-ui/core";
-import { MenuItem } from "@superset-ui/core/components/Menu";
-import { parse as parseContentDisposition } from "content-disposition";
-import { useDownloadScreenshot } from "src/dashboard/hooks/useDownloadScreenshot";
-import { NATIVE_FILTER_PREFIX } from "src/dashboard/components/nativeFilters/FiltersConfigModal/utils";
-import { MenuKeys, RootState } from "src/dashboard/types";
-import downloadAsPdf from "src/utils/downloadAsPdf";
-import downloadAsImage from "src/utils/downloadAsImage";
-import handleResourceExport from "src/utils/export";
+} from '@superset-ui/core';
+import { MenuItem } from '@superset-ui/core/components/Menu';
+import { parse as parseContentDisposition } from 'content-disposition';
+import { useDownloadScreenshot } from 'src/dashboard/hooks/useDownloadScreenshot';
+import { isEmbedded as isEmbeddedDashboard } from 'src/dashboard/util/isEmbedded';
+import { NATIVE_FILTER_PREFIX } from 'src/dashboard/components/nativeFilters/FiltersConfigModal/utils';
+import { MenuKeys, RootState } from 'src/dashboard/types';
+import downloadAsPdf from 'src/utils/downloadAsPdf';
+import downloadAsImage from 'src/utils/downloadAsImage';
+import handleResourceExport from 'src/utils/export';
+import { redirect } from 'src/utils/navigationUtils';
import {
LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_PDF,
LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE,
-} from "src/logger/LogUtils";
-import { useToasts } from "src/components/MessageToasts/withToasts";
+} from 'src/logger/LogUtils';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
-import { MenuItemTooltip } from "src/components/Chart/DisabledMenuItemTooltip";
-import { DownloadScreenshotFormat } from "./types";
+import { MenuItemTooltip } from 'src/components/Chart/DisabledMenuItemTooltip';
+import { DownloadScreenshotFormat } from './types';
// A guest/embedded session has no email address to be notified at, so rather
// than wait on that notification the frontend polls for completion instead;
// the same polling also drives the auto-download for a regular session,
// which arrives before its export email in practice.
const EXPORT_STATUS_POLL_INTERVAL_MS = 3000;
const EXPORT_STATUS_POLL_TIMEOUT_MS = 5 * 60 * 1000;
+// An embedded guest has no email fallback: if the client stops polling, a
+// slow-but-successful export is orphaned with no way to retrieve it. Outlive
+// the server's hard task budget (11 minutes) instead of racing it.
+const EMBEDDED_EXPORT_STATUS_POLL_TIMEOUT_MS = 12 * 60 * 1000;
Review Comment:
This timeout starts when the request is enqueued, but the Celery hard limit starts only when a worker begins running. A queued guest export can spend part of these twelve minutes waiting, then finish after polling has stopped; without email or a retained job handle, its successful artifact is unreachable. Could the timeout include queue delay or expose a resumable status/download path?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3866909117
##########
docs/docs/using-superset/exporting-dashboard-data.mdx:
##########
@@ -47,12 +47,31 @@ Notes on the generated workbook:
This feature is **disabled by default**. It requires:
-1. **The `boto3` dependency.** It is not installed by default; install it with
- `pip install apache-superset[excel-export]`. Without it, exports fail and the
- user receives a failure email.
-2. **An S3 bucket.** Set `EXCEL_EXPORT_S3_BUCKET`. Until it is set, the export
- endpoint returns `501` and the menu action surfaces a "not configured"
- message.
+1. **A storage bucket and backend.** Configure `EXPORT_STORAGE` with both
+ a `bucket` and a `backend` matching the bucket's provider — there is no
+ implicit default:
+
+ ```python
+ from superset.utils.s3 import S3ExportStorage # AWS S3
+ # from superset.utils.gcs import GCSExportStorage # Google Cloud Storage
+
+ EXPORT_STORAGE = {
+ "bucket": "my-export-bucket",
+ "backend": S3ExportStorage(),
+ }
+ ```
+
+ Until both are set, the export endpoint returns `501` and the menu action
+ surfaces a "not configured" message.
+2. **The backend's SDK dependency.** Not installed by default; install
+ `pip install apache-superset[excel-export]` (boto3) for `S3ExportStorage`,
+ or `pip install apache-superset[excel-export-gcs]` (google-cloud-storage)
+ for `GCSExportStorage`. Without it, exports fail and the user receives a
+ failure email. For `GCSExportStorage` with token-only Application Default
Review Comment:
The worker can upload successfully while this URL is later signed in the Flask web process. With separate web and worker identities, documenting only worker bucket write access leaves the web tier without the GCS signing/read permissions and every ready download fails. Could this spell out the web-tier requirements for `generate_download_url()` as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3816036088
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -451,26 +451,37 @@ def _handle_export_failure(
def export_dashboard_excel(
self: Any, # pylint: disable=unused-argument
dashboard_id: int,
- user_id: int,
+ user_id: int | None,
active_data_mask: dict[str, Any],
job_id: str,
mode: str = EXPORT_MODE_DATA,
+ guest_token: dict[str, Any] | None = None,
) -> None:
"""
Export a dashboard's charts to an ``.xlsx`` and record a download link.
:param dashboard_id: The dashboard to export
- :param user_id: The requesting user (the task runs with their permissions)
+ :param user_id: The requesting user (the task runs with their permissions),
+ or ``None`` for a guest/embedded requester
:param active_data_mask: Live dashboard filter state keyed by native filter id
:param job_id: Correlation id, also the Celery task id and S3 object name
:param mode: ``"data"`` streams every chart's tabular result; ``"images"``
embeds non-table charts as rendered images and keeps tables tabular
+ :param guest_token: The guest token payload when the requester is an
+ embedded guest; the guest user is reconstructed from it so the export
+ runs under the token's RLS rules and resource claims, never under an
+ elevated identity
"""
# pylint: disable=import-outside-toplevel
from superset.models.dashboard import Dashboard
requested_at = datetime.now(tz=timezone.utc)
- user = security_manager.get_user_by_id(user_id)
+ if user_id is not None:
+ user = security_manager.get_user_by_id(user_id)
+ elif guest_token:
+ user = security_manager.get_guest_user_from_token(guest_token)
+ else:
+ user = None
Review Comment:
**Suggestion:** The guest reconstruction runs before the `try`/`finally` that releases the distributed lock. If `get_guest_user_from_token` raises—for example because the guest role lookup or metadata access fails—the task exits without releasing the lock acquired by the API, leaving every guest export for that dashboard blocked until the TTL expires. Move user reconstruction inside the protected block or explicitly release the lock on this failure path. [missing cleanup]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Guest exports remain blocked until lock TTL expiry.
- ⚠️ All guests share the affected dashboard's slot-0 lock.
- ⚠️ Failure status is not recorded for this path.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/tasks/export_dashboard_excel.py
**Line:** 479:484
**Comment:**
*Missing Cleanup: The guest reconstruction runs before the `try`/`finally` that releases the distributed lock. If `get_guest_user_from_token` raises—for example because the guest role lookup or metadata access fails—the task exits without releasing the lock acquired by the API, leaving every guest export for that dashboard blocked until the TTL expires. Move user reconstruction inside the protected block or explicitly release the lock on this failure path.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43340&comment_hash=05f614621b5eb38aa7d628ab7971523edf5769a3049b2642cd07966b80450ca2&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43340&comment_hash=05f614621b5eb38aa7d628ab7971523edf5769a3049b2642cd07966b80450ca2&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz closed pull request #43340: fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id
URL: https://github.com/apache/superset/pull/43340
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867515017
##########
superset/dashboards/api.py:
##########
@@ -1814,7 +1828,12 @@ def export_xlsx(self, pk: int) -> WerkzeugResponse:
# otherwise) so the guard works across the web server and workers and is
# not a no-op under the default cache. The task releases it when it
# settles; the TTL is the backstop if that release is ever lost.
- lock_params = export_lock_params(g.user.id, dashboard.id)
+ # A guest/embedded requester has no DB-backed user id (GuestUser carries
+ # no ``id`` attribute at all), so all guests share lock slot 0 for the
+ # dashboard; the task reconstructs the guest (with the token's RLS rules
+ # and resource claims) from the token payload passed alongside.
+ user_id = get_user_id()
+ lock_params = export_lock_params(user_id or 0, dashboard.id)
try:
Review Comment:
This TTL starts at enqueue but the task's execution budget starts only when Celery picks it up, so queue delay can let the lock expire while the first export is still running. Could the worker renew/own the lock for its execution (and release only its own lease) so a delayed task cannot overlap or delete a later export's replacement lock?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3866913392
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -315,35 +337,37 @@ export const useDownloadMenuItems = (
...(userCanExport
? [
{
- key: "export-xlsx",
- label: t("Export Data to Excel"),
- onClick: () => onExportXlsx("data"),
+ key: 'export-xlsx',
+ label: t('Export Data to Excel'),
+ onClick: () => onExportXlsx('data'),
},
// Image export renders charts through the headless webdriver, so only
// offer it where that infrastructure is available (same signal as the
// PDF/PNG image downloads above); otherwise non-table charts would
- // silently come back empty.
- ...(isWebDriverScreenshotEnabled
+ // silently come back empty. Embedded sessions are excluded too: the
+ // webdriver cannot render Explore under a guest identity, so the
+ // export would burn its whole task budget and produce nothing.
+ ...(isWebDriverScreenshotEnabled && !isEmbedded
Review Comment:
Hiding this item only in the menu does not prevent a guest-token client from posting `mode=images` directly. The API then accepts an export the change itself says cannot render under a guest identity, holding the shared guest dashboard lock while the task runs to timeout. Could the API reject image mode for guest requests as well?
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -83,9 +89,28 @@ export const useDownloadMenuItems = (
canExportImage,
} = props;
- const { addDangerToast, addSuccessToast } = useToasts();
+ const { addDangerToast, addSuccessToast, addInfoToast } = useToasts();
const dataMask = useSelector((state: RootState) => state.dataMask);
- const SCREENSHOT_NODE_SELECTOR = ".dashboard";
+ // Embedded (iframe) sessions may have no email address, so they get
+ // delivery-neutral copy and a poll window that outlives the task budget.
+ const isEmbedded = isEmbeddedDashboard();
Review Comment:
`isEmbedded()` is frame detection rather than a guest-principal check. An authenticated user running Superset in an iframe now loses image export and receives the no-email copy even though their identity can render images and receive email. Could this branch use the session principal instead of iframe presence?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3866917386
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -190,36 +215,37 @@ export const useDownloadMenuItems = (
download_url: downloadUrl,
message,
} = json as ExportStatusResponse;
- if (status === "ready") {
+ if (status === 'ready') {
if (downloadUrl) {
- window.location.href = downloadUrl;
+ redirect(downloadUrl);
}
- addSuccessToast(t("Your export is ready and downloading."));
+ addSuccessToast(t('Your export is ready and downloading.'));
return;
}
- if (status === "error") {
+ if (status === 'error') {
addDangerToast(
- message || t("Sorry, something went wrong. Try again later."),
+ message || t('Sorry, something went wrong. Try again later.'),
);
return;
}
- if (Date.now() - startedAt > EXPORT_STATUS_POLL_TIMEOUT_MS) {
+ if (Date.now() - startedAt > pollTimeoutMs) {
addDangerToast(
- t("Your export is taking longer than expected. Try again later."),
+ t('Your export is taking longer than expected. Try again later.'),
);
return;
}
+ addExportPendingToast();
Review Comment:
This re-adds the pending info toast on every poll. Because the toast expires after four seconds while polling continues every three, it is recreated and announced repeatedly throughout a slow export—up to roughly 120 times during the embedded window. Could the pending status be shown once (or updated without a new alert) until the export reaches a terminal state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5432624250
Note: 2739f7e1fb referenced in the replies above was amended to 23b98735ac; the only delta is updating the google.auth.default fake in tests/unit_tests/utils/gcs_tests.py to accept the new scopes kwarg, which the previous push broke in CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3816054572
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -451,26 +451,37 @@ def _handle_export_failure(
def export_dashboard_excel(
self: Any, # pylint: disable=unused-argument
dashboard_id: int,
- user_id: int,
+ user_id: int | None,
active_data_mask: dict[str, Any],
job_id: str,
mode: str = EXPORT_MODE_DATA,
+ guest_token: dict[str, Any] | None = None,
) -> None:
"""
Export a dashboard's charts to an ``.xlsx`` and record a download link.
:param dashboard_id: The dashboard to export
- :param user_id: The requesting user (the task runs with their permissions)
+ :param user_id: The requesting user (the task runs with their permissions),
+ or ``None`` for a guest/embedded requester
:param active_data_mask: Live dashboard filter state keyed by native filter id
:param job_id: Correlation id, also the Celery task id and S3 object name
:param mode: ``"data"`` streams every chart's tabular result; ``"images"``
embeds non-table charts as rendered images and keeps tables tabular
+ :param guest_token: The guest token payload when the requester is an
+ embedded guest; the guest user is reconstructed from it so the export
+ runs under the token's RLS rules and resource claims, never under an
+ elevated identity
"""
# pylint: disable=import-outside-toplevel
from superset.models.dashboard import Dashboard
requested_at = datetime.now(tz=timezone.utc)
- user = security_manager.get_user_by_id(user_id)
+ if user_id is not None:
+ user = security_manager.get_user_by_id(user_id)
+ elif guest_token:
+ user = security_manager.get_guest_user_from_token(guest_token)
+ else:
+ user = None
Review Comment:
Good catch, fixed in 619bd266db: user resolution now happens inside the protected block, so a failing guest role lookup still releases the lock in the `finally` and still records a pollable failure status via `_handle_export_failure` (which tolerates `user=None`). Added `test_lock_released_and_failure_recorded_when_user_resolution_fails` covering exactly this path. Note the pre-existing code had the same latent gap with `get_user_by_id`, which this also closes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3878094994
##########
superset/config.py:
##########
@@ -1522,22 +1523,47 @@ def sync_theme_logo_href(
# note: index option should not be overridden
EXCEL_EXPORT: dict[str, Any] = {}
+
# ---------------------------------------------------
-# Dashboard "Export Data to Excel" (async, S3-backed)
+# Dashboard "Export Data to Excel" (async, object-storage-backed)
# ---------------------------------------------------
-# Destination S3 bucket for generated dashboard .xlsx exports. The feature is
-# disabled until this is set: the export endpoint returns 501 when it is None.
-EXCEL_EXPORT_S3_BUCKET: str | None = None
-# Key prefix for export objects: {prefix}{dashboard_id}/{job_id}.xlsx
-EXCEL_EXPORT_S3_KEY_PREFIX = "dashboard-exports/"
-# Lifetime (seconds) of the pre-signed download URL emailed to the user (24h).
-# Note: AWS S3 caps pre-signed URL lifetime at 7 days (604800 seconds); larger
-# values are rejected by S3, so keep this at or below that when using AWS.
+class ExportStorageConfig(TypedDict, total=False):
+ """Where generated export artifacts (dashboard Excel exports, and
+ potentially other export file types) are uploaded, and how the download
+ redirect resolves them back to a fresh URL. See EXPORT_STORAGE."""
+
+ # Destination bucket for generated export artifacts. The export feature is
+ # disabled until this is set: the export endpoint returns 501 while absent.
+ bucket: str
+ # Key/blob prefix for export objects: {prefix}{dashboard_id}/{job_id}.xlsx
+ # A callable is invoked per export, for deployments where the prefix is
+ # only known in request/task context (e.g. a multi-tenant installation
+ # scoping a shared bucket per tenant).
+ key_prefix: str | Callable[[], str]
+ # The storage backend (an instance implementing
+ # superset.utils.export_storage.ExportStorage), the same pattern as
+ # RESULTS_BACKEND or CUSTOM_SECURITY_MANAGER. There is no implicit
+ # default; the feature is disabled (the export endpoint returns 501)
+ # until one is set explicitly, matching the bucket's provider:
+ # from superset.utils.s3 import S3ExportStorage # AWS S3
+ # from superset.utils.gcs import GCSExportStorage # Google Cloud Storage
+ # EXPORT_STORAGE["backend"] = S3ExportStorage()
+ # S3ExportStorage accepts client_kwargs for boto3.client("s3", ...)
+ # overrides (region_name, or an endpoint_url for S3-compatible stores
+ # such as MinIO/LocalStack); credentials otherwise resolve through each
+ # SDK's standard chain.
+ backend: ExportStorage
+
+
+EXPORT_STORAGE: ExportStorageConfig = {
Review Comment:
This replaces the supported `EXCEL_EXPORT_S3_*` configuration with an empty `EXPORT_STORAGE` without a compatibility path. An existing S3 deployment that upgrades unchanged will now receive `501` for every export. Could the legacy settings be preserved as a deprecated fallback or migrated explicitly?
##########
superset/dashboards/api.py:
##########
@@ -1922,17 +1946,32 @@ def download_xlsx(self, job_id: uuid.UUID) -> WerkzeugResponse:
description: The job_id from the export_xlsx response
responses:
302:
- description: Redirect to a pre-signed S3 download URL
+ description: Redirect to a signed storage download URL
410:
description: The link is unknown, expired, or the export failed
+ 501:
+ description: Excel export is not configured on this server
"""
resolved = resolve_download_link(job_id)
if resolved is None:
return self.response(410, message="This download link has expired.")
- bucket, key = resolved
- return redirect(
- s3.generate_presigned_url(bucket, key, PRESIGNED_URL_TTL_SECONDS)
+ bucket, key, uploaded_backend = resolved
+ storage_backend = current_app.config["EXPORT_STORAGE"].get("backend")
+ if storage_backend is None:
+ # A link can only exist if a backend was configured when the export
+ # ran, so reaching this means the config was cleared since then.
+ return self.response(
+ 501, message="Excel export is not configured on this server."
+ )
+ backend_cls = type(storage_backend)
+ configured_backend = f"{backend_cls.__module__}.{backend_cls.__qualname__}"
+ if uploaded_backend is not None and uploaded_backend != configured_backend:
Review Comment:
This only compares the backend class, not the backend configuration. If an export is uploaded through `S3ExportStorage(endpoint_url=old-minio)` and the web tier switches to another `S3ExportStorage` endpoint, the check passes and the redirect signs the stored key against the wrong service. Could the stored link bind enough backend identity to reject this same-class migration too?
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -190,46 +208,53 @@ export const useDownloadMenuItems = (
download_url: downloadUrl,
message,
} = json as ExportStatusResponse;
- if (status === "ready") {
+ if (status === 'ready') {
if (downloadUrl) {
- window.location.href = downloadUrl;
+ redirect(downloadUrl);
Review Comment:
The no-email flow now depends on this URL, but the status endpoint builds it from `WEBDRIVER_BASEURL_USER_FRIENDLY`, whose default is `http://0.0.0.0:8080/`. In a normal deployment that has not configured the webdriver/email base URL, a guest export completes but redirects the browser to an unreachable address with no email fallback. Could the polling response use a same-origin download path or make this configuration an explicit prerequisite?
##########
superset/dashboards/api.py:
##########
@@ -1832,10 +1848,15 @@ def export_xlsx(self, pk: int) -> WerkzeugResponse:
export_dashboard_excel.apply_async(
kwargs={
"dashboard_id": dashboard.id,
- "user_id": g.user.id,
+ "user_id": user_id,
"active_data_mask": payload.get("active_data_mask", {}),
"job_id": job_id,
"mode": payload.get("mode", "data"),
+ "guest_token": (
Review Comment:
During a web-before-worker rollout, older workers still registered without `guest_token` reject this message before the task can record failure or release the lock. That leaves the export pending until its TTL expires. Could this be made rollout-compatible (for example by staging the task signature change or versioning the task)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5346861726
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867511990
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -83,9 +92,27 @@ export const useDownloadMenuItems = (
canExportImage,
} = props;
- const { addDangerToast, addSuccessToast } = useToasts();
+ const { addDangerToast, addSuccessToast, addInfoToast } = useToasts();
const dataMask = useSelector((state: RootState) => state.dataMask);
- const SCREENSHOT_NODE_SELECTOR = ".dashboard";
+ const user = useSelector((state: RootState) => state.user);
+ // Guests and anonymous sessions have no userId; sessions the backend
+ // cannot email get neutral copy and a poll window outliving the task budget.
+ const isGuestSession = !user?.userId;
+ const canReceiveEmail = Boolean(user?.userId && user?.email);
Review Comment:
Having an email address does not guarantee delivery: SMTP is optional and send failures are swallowed, while this path stops polling after five minutes even though the task can run longer. Could the browser keep polling through the task budget (or otherwise retain a fallback) so a successful export is not lost when email is unavailable?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867509623
##########
superset/utils/gcs.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+``ExportStorage`` implementation backed by Google Cloud Storage, for
+deployments where the export bucket is a native GCS bucket rather than S3.
+
+Set ``EXPORT_STORAGE["backend"] = GCSExportStorage()`` in
+``superset_config.py`` (vs ``superset.utils.s3.S3ExportStorage`` for an S3
+bucket). Authentication uses Application Default Credentials (a
+service account key, workload identity, etc.) via the standard
+``google-cloud-storage`` resolution chain -- there is no separate credential
+config here. Signed download URLs from token-only credentials (workload
+identity, GCE metadata, Cloud Run) are routed through the IAM signBlob API,
+which requires ``roles/iam.serviceAccountTokenCreator`` on the service
+account itself.
+"""
+
+from __future__ import annotations
+
+from datetime import timedelta
+from typing import Any
+
+
+def _get_client() -> Any:
+ """Build a GCS client using Application Default Credentials."""
+ # Imported lazily, mirroring superset.utils.s3.S3ExportStorage: importing
+ # this module (which happens at config-load time if EXPORT_STORAGE
+ # is set) should not require google-cloud-storage unless an export
+ # actually runs.
+ try:
+ from google.cloud import storage # pylint: disable=import-outside-toplevel
+ except ImportError as ex:
+ raise ImportError(
+ "google-cloud-storage is required for GCSExportStorage but is not "
+ "installed. Install it with "
+ "`pip install apache-superset[excel-export-gcs]`."
+ ) from ex
+
+ return storage.Client()
+
+
+class GCSExportStorage:
+ """``ExportStorage`` backed by Google Cloud Storage.
+
+ See ``superset.utils.export_storage.ExportStorage`` for the interface this
+ implements.
+ """
+
+ def upload_file(self, local_path: str, bucket: str, key: str) -> None:
+ """
+ Upload a local file to GCS.
+
+ :param local_path: Path to the file on local disk
+ :param bucket: Destination GCS bucket
+ :param key: Destination GCS blob name
+ """
+ _get_client().bucket(bucket).blob(key).upload_from_filename(local_path)
+
+ def generate_download_url(self, bucket: str, key: str, expires_in: int) -> str:
+ """
+ Generate a time-limited signed URL for downloading a GCS object.
+
+ Token-only Application Default Credentials (GKE workload identity, GCE
+ metadata, Cloud Run) carry no private key, so local V4 signing raises.
+ For those, route the signature through the IAM signBlob API by passing
+ ``service_account_email`` and ``access_token``; the service account
+ needs ``roles/iam.serviceAccountTokenCreator`` on itself.
+
+ :param bucket: The GCS bucket
+ :param key: The GCS blob name
+ :param expires_in: URL lifetime in seconds
+ :returns: A v4 signed URL
+ """
+ # pylint: disable=import-outside-toplevel
+ import google.auth
+ from google.auth import credentials as auth_credentials
+ from google.auth.transport import requests as auth_requests
+
+ blob = _get_client().bucket(bucket).blob(key)
+ signing_kwargs: dict[str, Any] = {}
+ credentials, _ = google.auth.default()
Review Comment:
Upload obtains Storage-scoped ADC, but the IAM-signing path reloads unscoped ADC; external-account/workload-identity credentials can then fail to mint the signBlob token even though upload succeeded. Could this request the required scope (or reuse explicitly scoped credentials) so those deployments do not get a 500 only when clicking the download link?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867493890
##########
superset/dashboards/excel_export/download_link.py:
##########
@@ -98,23 +99,38 @@ def build_download_url(job_id: UUID) -> str:
def create_download_link(
- job_id: UUID, bucket: str, key: str, expires_at: datetime
+ job_id: UUID, bucket: str, key: str, expires_at: datetime, backend: str
) -> str:
"""Record that ``job_id``'s export succeeded and is downloadable from
``key`` in ``bucket`` until ``expires_at``, and return the download URL
(used in the success email).
+ ``backend`` is the dotted path of the ``ExportStorage`` class that
+ uploaded the file; the download redirect refuses to sign with a different
+ backend (see ``download_xlsx``), failing clearly after a storage migration
+ instead of minting a URL for the wrong provider.
+
``expires_at`` should be a naive datetime in the same timezone convention
``KeyValueEntry.is_expired()`` compares against (naive ``datetime.now()``).
"""
_sweep_and_upsert(
job_id,
- {"status": STATUS_READY, "bucket": bucket, "key": key},
+ {"status": STATUS_READY, "bucket": bucket, "key": key, "backend": backend},
expires_at,
)
return build_download_url(job_id)
+def mark_export_running(job_id: UUID, expires_at: datetime) -> None:
+ """Record that a worker has started executing ``job_id`` (as opposed to
+ still sitting in the queue), so a polling client can wait out broker
+ backlog without racing the task's execution budget, which only starts
+ here. Overwritten by the terminal record; ``expires_at`` is the backstop
+ if the worker dies first.
+ """
+ _sweep_and_upsert(job_id, {"status": STATUS_RUNNING}, expires_at)
Review Comment:
The new running status is only added or mutated in the worker's SQLAlchemy session; neither path commits it, so concurrent status requests will not reliably see it. Could this commit the status update before workbook work begins, so queued no-email exports can actually reset their polling deadline when a worker starts?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867501245
##########
superset/dashboards/api.py:
##########
@@ -1795,6 +1801,14 @@ def export_xlsx(self, pk: int) -> WerkzeugResponse:
):
return self.response_404()
+ # The webdriver cannot render under a guest identity: the export would
+ # hold the shared guest lock for its whole budget and produce nothing.
+ # The UI hides the option for guests, but hiding is not enforcement.
+ if payload.get("mode") == "images" and security_manager.is_guest_user():
Review Comment:
The UI hides image export whenever `userId` is absent, but this rejects only guest-token users; a Public/anonymous requester can still POST `mode=images` directly. Could this use the same no-user-id predicate (or otherwise align the two gates) so an anonymous export cannot occupy the shared lock and fail in the webdriver path?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5346880805
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 4ad2fcdc99fa27ff2f3dcfa239a9ec70abb7c675 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a8600bd7b85590008a68281 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-43340--superset-docs-preview.netlify.app](https://deploy-preview-43340--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctBDoMgEEDRu8y6xKmJOPYGHgNktCTWIQMk2qZ3l83P37wfJJVPKvACeIBXdyzv9pvzUkSVs9b47dZ4Gj4X3luTaDFb5VxMzawmhgYDp12uOTRqHVlEH0ZPwzAhIjlLPT3hfwM) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-43340--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3866901465
##########
docs/docs/using-superset/exporting-dashboard-data.mdx:
##########
@@ -72,23 +91,25 @@ will not register.
## Configuration keys
-| Key | Default | Description |
-| ------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `EXCEL_EXPORT_S3_BUCKET` | `None` | Destination bucket. Required; `501` if unset. |
-| `EXCEL_EXPORT_S3_KEY_PREFIX` | `"dashboard-exports/"` | Key prefix: `{prefix}{dashboard_id}/{job_id}.xlsx`. |
-| `EXCEL_EXPORT_LINK_TTL_SECONDS` | `86400` | Lifetime of the pre-signed download URL (24h). |
-| `EXCEL_EXPORT_S3_CLIENT_KWARGS` | `{}` | Extra kwargs for `boto3.client("s3", ...)` — e.g. `region_name`, or `endpoint_url` for MinIO/LocalStack. |
-| `EXCEL_EXPORT_TABLE_VIZ_TYPES` | `None` | Viz types kept tabular in **Export Images to Excel** mode; every other type is embedded as an image. `None` uses the built-in default (`table`, `pivot_table`, `pivot_table_v2`). |
-| `EXCEL_EXPORT_QUERY_CONTEXT_BUILDER` | `None` | Optional `Callable[[form_data_dict], dict \| None]` to build a query context for a chart missing a saved one, tried before the built-in form-data rebuild. Point it at a service that runs the chart's real frontend `buildQuery` to faithfully export viz types the built-in rebuild can't handle. Must return `None` when it can't build faithfully, so the export falls back. |
-
-Credentials and region resolve through the standard boto3 chain (environment
-variables, shared config, or instance role) unless overridden via
-`EXCEL_EXPORT_S3_CLIENT_KWARGS`. The worker needs `s3:PutObject` on the bucket.
+| Key | Default | Description |
+| -------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `EXPORT_STORAGE["bucket"]` | unset | Destination bucket. Required; `501` if unset. |
+| `EXPORT_STORAGE["backend"]` | unset | Storage backend instance: `S3ExportStorage()` (`superset.utils.s3`), `GCSExportStorage()` (`superset.utils.gcs`), or a custom `superset.utils.export_storage.ExportStorage` implementation. Required; `501` if unset. |
+| `EXPORT_STORAGE["key_prefix"]` | `"dashboard-exports/"` | Object key/blob prefix: `{prefix}{dashboard_id}/{job_id}.xlsx`. A callable (`() -> str`) is invoked per export, for prefixes only known in request/task context (e.g. per-tenant scoping of a shared bucket). |
+| `EXCEL_EXPORT_LINK_TTL_SECONDS` | `86400` | Lifetime of the pre-signed download URL (24h). |
Review Comment:
This setting expires Superset's stored download link, not the storage URL: the redirect creates a fresh URL with the five-minute `PRESIGNED_URL_TTL_SECONDS`. An operator who copies the signed URL expecting this configured lifetime will see it expire early. Could the description distinguish the link-record lifetime from the minted storage URL lifetime?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867274331
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -83,9 +89,28 @@ export const useDownloadMenuItems = (
canExportImage,
} = props;
- const { addDangerToast, addSuccessToast } = useToasts();
+ const { addDangerToast, addSuccessToast, addInfoToast } = useToasts();
const dataMask = useSelector((state: RootState) => state.dataMask);
- const SCREENSHOT_NODE_SELECTOR = ".dashboard";
+ // Embedded (iframe) sessions may have no email address, so they get
+ // delivery-neutral copy and a poll window that outlives the task budget.
+ const isEmbedded = isEmbeddedDashboard();
Review Comment:
Fixed in c75abca73a alongside the other identity comment: delivery copy and the poll window now follow the requester identity, so sessions the backend cannot email get the neutral copy and the 12 minute window. The task also records a running status when a worker picks the job up, and the client restarts its wait window on observing it, so queue delay is no longer counted against the export and a queued guest export is not orphaned. Jest tests cover both.
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -190,36 +215,37 @@ export const useDownloadMenuItems = (
download_url: downloadUrl,
message,
} = json as ExportStatusResponse;
- if (status === "ready") {
+ if (status === 'ready') {
if (downloadUrl) {
- window.location.href = downloadUrl;
+ redirect(downloadUrl);
}
- addSuccessToast(t("Your export is ready and downloading."));
+ addSuccessToast(t('Your export is ready and downloading.'));
return;
}
- if (status === "error") {
+ if (status === 'error') {
addDangerToast(
- message || t("Sorry, something went wrong. Try again later."),
+ message || t('Sorry, something went wrong. Try again later.'),
);
return;
}
- if (Date.now() - startedAt > EXPORT_STATUS_POLL_TIMEOUT_MS) {
+ if (Date.now() - startedAt > pollTimeoutMs) {
addDangerToast(
- t("Your export is taking longer than expected. Try again later."),
+ t('Your export is taking longer than expected. Try again later.'),
);
return;
}
+ addExportPendingToast();
Review Comment:
Kept as is deliberately: this mirrors useDownloadScreenshot's existing repeating info toast with noDuplicate, and consistency between the two download flows matters more to us than reducing the re announcements. Happy to revisit both flows together in a follow up if the repetition proves to be a real problem.
##########
superset/dashboards/api.py:
##########
@@ -1922,17 +1937,27 @@ def download_xlsx(self, job_id: uuid.UUID) -> WerkzeugResponse:
description: The job_id from the export_xlsx response
responses:
302:
- description: Redirect to a pre-signed S3 download URL
+ description: Redirect to a signed storage download URL
410:
description: The link is unknown, expired, or the export failed
+ 501:
+ description: Excel export is not configured on this server
"""
resolved = resolve_download_link(job_id)
if resolved is None:
return self.response(410, message="This download link has expired.")
bucket, key = resolved
- return redirect(
- s3.generate_presigned_url(bucket, key, PRESIGNED_URL_TTL_SECONDS)
+ storage_backend = current_app.config["EXPORT_STORAGE"].get("backend")
Review Comment:
Addressed in c75abca73a with a deliberately minimal shape: the link record stores the dotted path of the uploading backend, and the download redirect refuses to sign when the configured backend differs, returning the same 410 as an expired link. Legacy records without the field keep signing with the configured backend. Reconstructing the original backend felt like overreach, since a replaced backend instance and its constructor kwargs no longer exist in config; failing clearly beats redirecting to a URL for the wrong provider. Integration tests cover the mismatch and the legacy record path.
##########
docs/docs/using-superset/exporting-dashboard-data.mdx:
##########
@@ -72,23 +91,25 @@ will not register.
## Configuration keys
-| Key | Default | Description |
-| ------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `EXCEL_EXPORT_S3_BUCKET` | `None` | Destination bucket. Required; `501` if unset. |
-| `EXCEL_EXPORT_S3_KEY_PREFIX` | `"dashboard-exports/"` | Key prefix: `{prefix}{dashboard_id}/{job_id}.xlsx`. |
-| `EXCEL_EXPORT_LINK_TTL_SECONDS` | `86400` | Lifetime of the pre-signed download URL (24h). |
-| `EXCEL_EXPORT_S3_CLIENT_KWARGS` | `{}` | Extra kwargs for `boto3.client("s3", ...)` — e.g. `region_name`, or `endpoint_url` for MinIO/LocalStack. |
-| `EXCEL_EXPORT_TABLE_VIZ_TYPES` | `None` | Viz types kept tabular in **Export Images to Excel** mode; every other type is embedded as an image. `None` uses the built-in default (`table`, `pivot_table`, `pivot_table_v2`). |
-| `EXCEL_EXPORT_QUERY_CONTEXT_BUILDER` | `None` | Optional `Callable[[form_data_dict], dict \| None]` to build a query context for a chart missing a saved one, tried before the built-in form-data rebuild. Point it at a service that runs the chart's real frontend `buildQuery` to faithfully export viz types the built-in rebuild can't handle. Must return `None` when it can't build faithfully, so the export falls back. |
-
-Credentials and region resolve through the standard boto3 chain (environment
-variables, shared config, or instance role) unless overridden via
-`EXCEL_EXPORT_S3_CLIENT_KWARGS`. The worker needs `s3:PutObject` on the bucket.
+| Key | Default | Description |
+| -------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `EXPORT_STORAGE["bucket"]` | unset | Destination bucket. Required; `501` if unset. |
+| `EXPORT_STORAGE["backend"]` | unset | Storage backend instance: `S3ExportStorage()` (`superset.utils.s3`), `GCSExportStorage()` (`superset.utils.gcs`), or a custom `superset.utils.export_storage.ExportStorage` implementation. Required; `501` if unset. |
Review Comment:
Fixed in c75abca73a: the Limitations section now documents the guest polling flow (auto download, no email fallback, images unavailable), and SMTP is documented as needed for email delivery only.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867504892
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -441,6 +453,59 @@ def _handle_export_failure(
logger.exception("Failed to record export failure status for %s", job_id)
+def _resolve_export_storage(
+ dashboard_id: int, job_id: str
+) -> tuple[ExportStorage, str, str]:
+ """The configured storage backend, bucket, and this export's object key.
+
+ The API already rejects the request with 501 when either the bucket or
+ the backend is unset, so reaching this unconfigured normally means
+ EXPORT_STORAGE was cleared after the job was enqueued (or the task
+ was invoked directly, bypassing the API). Fail with a clear message
+ instead of an opaque storage-SDK error.
+ """
+ storage_config = current_app.config["EXPORT_STORAGE"]
+ bucket = storage_config.get("bucket")
+ storage_backend = storage_config.get("backend")
+ if not bucket or storage_backend is None:
+ raise SupersetException(
+ "Excel export is not configured on this server: "
+ "EXPORT_STORAGE needs both a 'bucket' and a 'backend' "
+ "(e.g. superset.utils.s3.S3ExportStorage())."
+ )
+ key_prefix = storage_config.get("key_prefix", "dashboard-exports/")
+ if callable(key_prefix):
+ # A callable prefix is resolved per export, for deployments where it
+ # is only known in task context (e.g. a multi-tenant installation
+ # scoping a shared bucket per tenant).
+ key_prefix = key_prefix()
+ return storage_backend, bucket, f"{key_prefix}{dashboard_id}/{job_id}.xlsx"
+
+
+def _mark_running(job_id: str) -> None:
+ """Tell pollers execution has begun (vs. queued); best-effort, the export
+ must not fail over a status write."""
+ try:
+ expires_at = datetime.now(tz=timezone.utc) + timedelta(
+ seconds=EXPORT_HARD_TIME_LIMIT + 300
+ )
+ mark_export_running(uuid.UUID(job_id), expires_at.replace(tzinfo=None))
+ except Exception: # pylint: disable=broad-except
+ logger.exception("Failed to record running status for %s", job_id)
+
+
+def _resolve_requesting_user(
+ user_id: int | None, guest_token: GuestToken | None
+) -> Any:
+ if user_id is not None:
+ return security_manager.get_user_by_id(user_id)
+ if guest_token:
+ return security_manager.get_guest_user_from_token(guest_token)
Review Comment:
This rebuilds the guest principal from the already-decoded payload, so a task that waits in Celery can run after the token expires or is revoked. Could the worker revalidate the guest token/claims before querying chart data, so delayed exports do not continue using stale guest access?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5515342044
Superseded by #43805, which consolidates this stack with #43336 onto current master (same commits, review fixes included, suites green). Closing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5346906590
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43340?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `12.50000%` with `7 lines` in your changes missing coverage. Please review.
:warning: Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`fix/excel-export-guest-sessions-and-s3-link-expiry@26fabcf`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#section-missing-base-commit) about missing BASE report.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/43340?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/tasks/export\_dashboard\_excel.py](https://app.codecov.io/gh/apache/superset/pull/43340?src=pr&el=tree&filepath=superset%2Ftasks%2Fexport_dashboard_excel.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdGFza3MvZXhwb3J0X2Rhc2hib2FyZF9leGNlbC5weQ==) | 0.00% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43340?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/dashboards/api.py](https://app.codecov.io/gh/apache/superset/pull/43340?src=pr&el=tree&filepath=superset%2Fdashboards%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9hcGkucHk=) | 33.33% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43340?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## fix/excel-export-guest-sessions-and-s3-link-expiry #43340 +/- ##
=====================================================================================
Coverage ? 57.24%
=====================================================================================
Files ? 2874
Lines ? 163700
Branches ? 37776
=====================================================================================
Hits ? 93705
Misses ? 69106
Partials ? 889
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/43340/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [presto](https://app.codecov.io/gh/apache/superset/pull/43340/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.12% <12.50%> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/43340/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.12% <12.50%> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43340?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3866888425
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -451,31 +491,45 @@ def _handle_export_failure(
def export_dashboard_excel(
self: Any, # pylint: disable=unused-argument
dashboard_id: int,
- user_id: int,
+ user_id: int | None,
active_data_mask: dict[str, Any],
job_id: str,
mode: str = EXPORT_MODE_DATA,
+ guest_token: GuestToken | None = None,
) -> None:
"""
Export a dashboard's charts to an ``.xlsx`` and record a download link.
:param dashboard_id: The dashboard to export
- :param user_id: The requesting user (the task runs with their permissions)
+ :param user_id: The requesting user (the task runs with their permissions),
+ or ``None`` for a guest/embedded requester
:param active_data_mask: Live dashboard filter state keyed by native filter id
- :param job_id: Correlation id, also the Celery task id and S3 object name
+ :param job_id: Correlation id, also the Celery task id and storage object name
:param mode: ``"data"`` streams every chart's tabular result; ``"images"``
embeds non-table charts as rendered images and keeps tables tabular
+ :param guest_token: The guest token payload when the requester is an
+ embedded guest; the guest user is reconstructed from it so the export
+ runs under the token's RLS rules and resource claims, never under an
+ elevated identity
"""
# pylint: disable=import-outside-toplevel
from superset.models.dashboard import Dashboard
requested_at = datetime.now(tz=timezone.utc)
- user = security_manager.get_user_by_id(user_id)
+ user = None
dashboard_title = ""
tmp_path: str | None = None
ttl = current_app.config["EXCEL_EXPORT_LINK_TTL_SECONDS"]
try:
+ # Resolve the user inside the protected block: if this raises (e.g. the
+ # guest role lookup fails), the ``finally`` below must still release the
+ # lock the API acquired, and the failure status must still be recorded
+ # for pollers.
+ if user_id is not None:
+ user = security_manager.get_user_by_id(user_id)
+ elif guest_token:
Review Comment:
For a Public/anonymous requester, `get_user_id()` is also `None` but no guest token is present, so this leaves `user` unset. The worker then runs chart queries without the Public role; a permitted anonymous export can complete with failures or an empty workbook. Should this load the anonymous user on the no-token branch?
##########
superset/dashboards/api.py:
##########
@@ -1922,17 +1937,27 @@ def download_xlsx(self, job_id: uuid.UUID) -> WerkzeugResponse:
description: The job_id from the export_xlsx response
responses:
302:
- description: Redirect to a pre-signed S3 download URL
+ description: Redirect to a signed storage download URL
410:
description: The link is unknown, expired, or the export failed
+ 501:
+ description: Excel export is not configured on this server
"""
resolved = resolve_download_link(job_id)
if resolved is None:
return self.response(410, message="This download link has expired.")
bucket, key = resolved
- return redirect(
- s3.generate_presigned_url(bucket, key, PRESIGNED_URL_TTL_SECONDS)
+ storage_backend = current_app.config["EXPORT_STORAGE"].get("backend")
Review Comment:
The job stores no backend identity, so a file uploaded under S3 will be signed with the GCS backend after a storage migration or mixed rollout. Existing links then fail during their advertised lifetime. Could the upload backend be captured with the job and used for the download redirect?
##########
docs/docs/using-superset/exporting-dashboard-data.mdx:
##########
@@ -72,23 +91,25 @@ will not register.
## Configuration keys
-| Key | Default | Description |
-| ------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `EXCEL_EXPORT_S3_BUCKET` | `None` | Destination bucket. Required; `501` if unset. |
-| `EXCEL_EXPORT_S3_KEY_PREFIX` | `"dashboard-exports/"` | Key prefix: `{prefix}{dashboard_id}/{job_id}.xlsx`. |
-| `EXCEL_EXPORT_LINK_TTL_SECONDS` | `86400` | Lifetime of the pre-signed download URL (24h). |
-| `EXCEL_EXPORT_S3_CLIENT_KWARGS` | `{}` | Extra kwargs for `boto3.client("s3", ...)` — e.g. `region_name`, or `endpoint_url` for MinIO/LocalStack. |
-| `EXCEL_EXPORT_TABLE_VIZ_TYPES` | `None` | Viz types kept tabular in **Export Images to Excel** mode; every other type is embedded as an image. `None` uses the built-in default (`table`, `pivot_table`, `pivot_table_v2`). |
-| `EXCEL_EXPORT_QUERY_CONTEXT_BUILDER` | `None` | Optional `Callable[[form_data_dict], dict \| None]` to build a query context for a chart missing a saved one, tried before the built-in form-data rebuild. Point it at a service that runs the chart's real frontend `buildQuery` to faithfully export viz types the built-in rebuild can't handle. Must return `None` when it can't build faithfully, so the export falls back. |
-
-Credentials and region resolve through the standard boto3 chain (environment
-variables, shared config, or instance role) unless overridden via
-`EXCEL_EXPORT_S3_CLIENT_KWARGS`. The worker needs `s3:PutObject` on the bucket.
+| Key | Default | Description |
+| -------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `EXPORT_STORAGE["bucket"]` | unset | Destination bucket. Required; `501` if unset. |
+| `EXPORT_STORAGE["backend"]` | unset | Storage backend instance: `S3ExportStorage()` (`superset.utils.s3`), `GCSExportStorage()` (`superset.utils.gcs`), or a custom `superset.utils.export_storage.ExportStorage` implementation. Required; `501` if unset. |
Review Comment:
This updated configuration section still leaves the Limitations section below saying guest-token exports are unsupported and lists SMTP as required, although this change adds guest-token task reconstruction and polling. Could the docs distinguish the no-email guest delivery path and document the supported flow?
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -83,9 +89,28 @@ export const useDownloadMenuItems = (
canExportImage,
} = props;
- const { addDangerToast, addSuccessToast } = useToasts();
+ const { addDangerToast, addSuccessToast, addInfoToast } = useToasts();
const dataMask = useSelector((state: RootState) => state.dataMask);
- const SCREENSHOT_NODE_SELECTOR = ".dashboard";
+ // Embedded (iframe) sessions may have no email address, so they get
+ // delivery-neutral copy and a poll window that outlives the task budget.
+ const isEmbedded = isEmbeddedDashboard();
Review Comment:
This treats only iframe embedding as no-email. A top-level Public/anonymous user is also returned as `user_id=None` and cannot receive email, but gets the five-minute poll timeout while the task can run for ten minutes; a successful export can then be orphaned. Could the delivery and polling behavior use the requester identity/email rather than iframe detection?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867484878
##########
UPDATING.md:
##########
@@ -274,19 +274,32 @@ Note that a retried query returns partial data with no truncation indicator
(e.g. a filter dropdown may list only a subset of values on tables above the
row cap).
-### Dashboard "Export Data to Excel" requires a Celery worker and S3 bucket
+### Dashboard "Export Data to Excel" requires a Celery worker and a storage bucket
A new dashboard action exports every chart's data to a single multi-sheet
`.xlsx` asynchronously. It is disabled by default and turns on only when
-`EXCEL_EXPORT_S3_BUCKET` is set (the endpoint returns `501` otherwise). It also
-requires a running Celery worker and a configured SMTP transport, since the task
-emails the requesting user a pre-signed download link. New config keys:
-`EXCEL_EXPORT_S3_BUCKET`, `EXCEL_EXPORT_S3_KEY_PREFIX`,
-`EXCEL_EXPORT_LINK_TTL_SECONDS`, `EXCEL_EXPORT_S3_CLIENT_KWARGS`,
+`EXPORT_STORAGE` is configured with both a `bucket` and a `backend` (the
+endpoint returns `501` otherwise) — there is no implicit storage default:
+
+```python
+from superset.utils.s3 import S3ExportStorage # or superset.utils.gcs.GCSExportStorage
+
+EXPORT_STORAGE = {
+ "bucket": "my-export-bucket",
+ "backend": S3ExportStorage(),
+}
+```
+
+It also requires a running Celery worker and a configured SMTP transport, since
Review Comment:
This still says SMTP is required, but guest/Public exports now finish through status polling and automatic download without an email address. Could this make SMTP conditional on email delivery so operators do not treat that supported flow as misconfigured?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867273240
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -451,31 +491,45 @@ def _handle_export_failure(
def export_dashboard_excel(
self: Any, # pylint: disable=unused-argument
dashboard_id: int,
- user_id: int,
+ user_id: int | None,
active_data_mask: dict[str, Any],
job_id: str,
mode: str = EXPORT_MODE_DATA,
+ guest_token: GuestToken | None = None,
) -> None:
"""
Export a dashboard's charts to an ``.xlsx`` and record a download link.
:param dashboard_id: The dashboard to export
- :param user_id: The requesting user (the task runs with their permissions)
+ :param user_id: The requesting user (the task runs with their permissions),
+ or ``None`` for a guest/embedded requester
:param active_data_mask: Live dashboard filter state keyed by native filter id
- :param job_id: Correlation id, also the Celery task id and S3 object name
+ :param job_id: Correlation id, also the Celery task id and storage object name
:param mode: ``"data"`` streams every chart's tabular result; ``"images"``
embeds non-table charts as rendered images and keeps tables tabular
+ :param guest_token: The guest token payload when the requester is an
+ embedded guest; the guest user is reconstructed from it so the export
+ runs under the token's RLS rules and resource claims, never under an
+ elevated identity
"""
# pylint: disable=import-outside-toplevel
from superset.models.dashboard import Dashboard
requested_at = datetime.now(tz=timezone.utc)
- user = security_manager.get_user_by_id(user_id)
+ user = None
dashboard_title = ""
tmp_path: str | None = None
ttl = current_app.config["EXCEL_EXPORT_LINK_TTL_SECONDS"]
try:
+ # Resolve the user inside the protected block: if this raises (e.g. the
+ # guest role lookup fails), the ``finally`` below must still release the
+ # lock the API acquired, and the failure status must still be recorded
+ # for pollers.
+ if user_id is not None:
+ user = security_manager.get_user_by_id(user_id)
+ elif guest_token:
Review Comment:
Fixed in c75abca73a: the no token branch now loads the anonymous principal, mirroring superset.tasks.async_queries, so Public role permissions apply to each chart's access check. Covered by test_anonymous_export_runs_under_the_anonymous_principal.
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -315,35 +337,37 @@ export const useDownloadMenuItems = (
...(userCanExport
? [
{
- key: "export-xlsx",
- label: t("Export Data to Excel"),
- onClick: () => onExportXlsx("data"),
+ key: 'export-xlsx',
+ label: t('Export Data to Excel'),
+ onClick: () => onExportXlsx('data'),
},
// Image export renders charts through the headless webdriver, so only
// offer it where that infrastructure is available (same signal as the
// PDF/PNG image downloads above); otherwise non-table charts would
- // silently come back empty.
- ...(isWebDriverScreenshotEnabled
+ // silently come back empty. Embedded sessions are excluded too: the
+ // webdriver cannot render Explore under a guest identity, so the
+ // export would burn its whole task budget and produce nothing.
+ ...(isWebDriverScreenshotEnabled && !isEmbedded
Review Comment:
Fixed in c75abca73a: export_xlsx now returns 403 for mode=images when security_manager.is_guest_user(), before the lock is acquired, so a direct POST cannot hold the shared guest slot. Covered by test_export_xlsx_images_403_for_guest.
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -83,9 +89,28 @@ export const useDownloadMenuItems = (
canExportImage,
} = props;
- const { addDangerToast, addSuccessToast } = useToasts();
+ const { addDangerToast, addSuccessToast, addInfoToast } = useToasts();
const dataMask = useSelector((state: RootState) => state.dataMask);
- const SCREENSHOT_NODE_SELECTOR = ".dashboard";
+ // Embedded (iframe) sessions may have no email address, so they get
+ // delivery-neutral copy and a poll window that outlives the task budget.
+ const isEmbedded = isEmbeddedDashboard();
Review Comment:
Fixed in c75abca73a: the branch now keys off the session principal (userId and email from the user state) instead of iframe detection. An authenticated user in an iframe keeps image export and the email copy; an anonymous session at the top level gets the neutral copy and the long poll window. isEmbedded is no longer imported there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3867275405
##########
docs/docs/using-superset/exporting-dashboard-data.mdx:
##########
@@ -72,23 +91,25 @@ will not register.
## Configuration keys
-| Key | Default | Description |
-| ------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `EXCEL_EXPORT_S3_BUCKET` | `None` | Destination bucket. Required; `501` if unset. |
-| `EXCEL_EXPORT_S3_KEY_PREFIX` | `"dashboard-exports/"` | Key prefix: `{prefix}{dashboard_id}/{job_id}.xlsx`. |
-| `EXCEL_EXPORT_LINK_TTL_SECONDS` | `86400` | Lifetime of the pre-signed download URL (24h). |
-| `EXCEL_EXPORT_S3_CLIENT_KWARGS` | `{}` | Extra kwargs for `boto3.client("s3", ...)` — e.g. `region_name`, or `endpoint_url` for MinIO/LocalStack. |
-| `EXCEL_EXPORT_TABLE_VIZ_TYPES` | `None` | Viz types kept tabular in **Export Images to Excel** mode; every other type is embedded as an image. `None` uses the built-in default (`table`, `pivot_table`, `pivot_table_v2`). |
-| `EXCEL_EXPORT_QUERY_CONTEXT_BUILDER` | `None` | Optional `Callable[[form_data_dict], dict \| None]` to build a query context for a chart missing a saved one, tried before the built-in form-data rebuild. Point it at a service that runs the chart's real frontend `buildQuery` to faithfully export viz types the built-in rebuild can't handle. Must return `None` when it can't build faithfully, so the export falls back. |
-
-Credentials and region resolve through the standard boto3 chain (environment
-variables, shared config, or instance role) unless overridden via
-`EXCEL_EXPORT_S3_CLIENT_KWARGS`. The worker needs `s3:PutObject` on the bucket.
+| Key | Default | Description |
+| -------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `EXPORT_STORAGE["bucket"]` | unset | Destination bucket. Required; `501` if unset. |
+| `EXPORT_STORAGE["backend"]` | unset | Storage backend instance: `S3ExportStorage()` (`superset.utils.s3`), `GCSExportStorage()` (`superset.utils.gcs`), or a custom `superset.utils.export_storage.ExportStorage` implementation. Required; `501` if unset. |
+| `EXPORT_STORAGE["key_prefix"]` | `"dashboard-exports/"` | Object key/blob prefix: `{prefix}{dashboard_id}/{job_id}.xlsx`. A callable (`() -> str`) is invoked per export, for prefixes only known in request/task context (e.g. per-tenant scoping of a shared bucket). |
+| `EXCEL_EXPORT_LINK_TTL_SECONDS` | `86400` | Lifetime of the pre-signed download URL (24h). |
Review Comment:
Fixed in c75abca73a: the config table now distinguishes the link record lifetime from the five minute storage URL minted fresh on each click.
##########
docs/docs/using-superset/exporting-dashboard-data.mdx:
##########
@@ -47,12 +47,31 @@ Notes on the generated workbook:
This feature is **disabled by default**. It requires:
-1. **The `boto3` dependency.** It is not installed by default; install it with
- `pip install apache-superset[excel-export]`. Without it, exports fail and the
- user receives a failure email.
-2. **An S3 bucket.** Set `EXCEL_EXPORT_S3_BUCKET`. Until it is set, the export
- endpoint returns `501` and the menu action surfaces a "not configured"
- message.
+1. **A storage bucket and backend.** Configure `EXPORT_STORAGE` with both
+ a `bucket` and a `backend` matching the bucket's provider — there is no
+ implicit default:
+
+ ```python
+ from superset.utils.s3 import S3ExportStorage # AWS S3
+ # from superset.utils.gcs import GCSExportStorage # Google Cloud Storage
+
+ EXPORT_STORAGE = {
+ "bucket": "my-export-bucket",
+ "backend": S3ExportStorage(),
+ }
+ ```
+
+ Until both are set, the export endpoint returns `501` and the menu action
+ surfaces a "not configured" message.
+2. **The backend's SDK dependency.** Not installed by default; install
+ `pip install apache-superset[excel-export]` (boto3) for `S3ExportStorage`,
+ or `pip install apache-superset[excel-export-gcs]` (google-cloud-storage)
+ for `GCSExportStorage`. Without it, exports fail and the user receives a
+ failure email. For `GCSExportStorage` with token-only Application Default
Review Comment:
Fixed in c75abca73a: the credentials paragraph now spells out both tiers, the worker uploading and the web server signing at click time, including the GCS signBlob case for token only credentials.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(dashboard): resolve guest users in Excel export instead of crashing on g.user.id [superset]
Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on PR #43340:
URL: https://github.com/apache/superset/pull/43340#issuecomment-5456770859
Design change in ee331bc783, driven by a production failure: on GKE clusters using direct workload identity federation (IAM grants to the Kubernetes principal, no Google service account bound), every download click failed with TransportError from the IAM signBytes API: 400 "Invalid form of account ID <project>.svc.id.goog". There is no service account to sign as in that identity mode, so no signing design can work there.
The download endpoint now streams the object through Superset with the deployment's own storage credentials instead of redirecting to a signed URL. The ExportStorage protocol swaps generate_download_url for a chunked download method (FileNotFoundError becomes a clean 410), and the whole signing apparatus is removed: the GCS signBlob fallback, the serviceAccountTokenCreator prerequisite, the presigned TTL, and their docs. Security model is unchanged (the unguessable job id remains the credential) and strictly tighter: no transferable bearer URL is ever minted, and every download is observable and revocable server side. Unit and integration suites updated and green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org