Skip to content

Commit 921dd08

Browse files
eschuthoclaudesadpandajoe
authored
fix(reports): fail cleanly and notify the owner when a tab/filter report has no valid executor (#46063)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Joe Li <joe@preset.io> Co-authored-by: sadpandajoe <jcli38@gmail.com>
1 parent 26beb62 commit 921dd08

3 files changed

Lines changed: 349 additions & 5 deletions

File tree

‎superset/commands/report/execute.py‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,19 +831,41 @@ def _get_failure_notification_url(self) -> str:
831831
notification fail too.
832832
"""
833833
try:
834+
if get_user() is None and self._report_schedule.dashboard is not None:
835+
# Terminal-error handling can run outside the executor's user
836+
# context; build the stateful link as the resolved executor.
837+
# Chart reports never need a user for their link and have no
838+
# dashboard to fall back to, so they use ``_get_url`` directly.
839+
executor, _ = resolve_executor_user(self._report_schedule)
840+
with override_user(executor):
841+
return self._get_url(user_friendly=True)
834842
return self._get_url(user_friendly=True)
835-
except ReportScheduleExecutorAccessDeniedError:
843+
except (
844+
ReportScheduleExecutorAccessDeniedError,
845+
ReportScheduleExecutorNotFoundError,
846+
):
836847
return self._get_plain_dashboard_url(user_friendly=True)
837848

838-
def _raise_for_executor_dashboard_access(self) -> None:
849+
def _raise_for_executor_dashboard_access(
850+
self, require_executor: bool = False
851+
) -> None:
839852
"""
840853
Fail with an actionable error when the executor cannot see the dashboard.
841854
842855
Without this, a plain dashboard URL renders the not-found page for the
843856
executor and surfaces only as a generic screenshot failure.
844857
"""
845858
user = get_user()
846-
if user is None or getattr(user, "is_anonymous", False):
859+
if getattr(user, "is_anonymous", False):
860+
return
861+
if user is None:
862+
# No user context. When a permalink is about to be created, surface
863+
# an unresolved executor as the same actionable error the screenshot
864+
# step raises, instead of failing on a missing ``g.user``. A
865+
# resolvable executor is applied by callers that wrap in
866+
# ``override_user``.
867+
if require_executor:
868+
resolve_executor_user(self._report_schedule)
847869
return
848870
dashboard = self._report_schedule.dashboard
849871
try:
@@ -976,7 +998,7 @@ def _get_tab_url(
976998
# without passing through ``get_dashboard_urls``, so the executor
977999
# check lives here to turn an exclusion (which the permalink command
9781000
# reports as not-found) into the access-denied error callers handle.
979-
self._raise_for_executor_dashboard_access()
1001+
self._raise_for_executor_dashboard_access(require_executor=True)
9801002
force = self._get_force_param()
9811003
# ``Superset.dashboard_permalink`` redirects by appending this
9821004
# state's ``urlParams`` *before* its own query string (which is

0 commit comments

Comments
 (0)