Skip to content

fix(reports): fail cleanly and notify the owner when a tab/filter report has no valid executor - #46063

Merged
sadpandajoe merged 4 commits into
masterfrom
fix-report-no-executor-tab-filter-crash
Nov 21, 2026
Merged

sadpandajoe merged 4 commits into
masterfrom
fix-report-no-executor-tab-filter-crash

Conversation

@eschutho

@eschutho eschutho commented Nov 7, 2026

Copy link
Copy Markdown
Member

SUMMARY

A dashboard report or alert that has a tab or native filters, and no valid executor (run-as user), crashed with 'NoneType' object has no attribute 'is_anonymous', and the owner received no failure email. The same report without a tab or filters failed cleanly with "Scheduled task executor not found" and emailed the owner.

Root cause: when the executor can't be resolved, get_executor_user returns (None, None) and the run proceeds with g.user unset. A plain report fails later, in the screenshot step, with ReportScheduleExecutorNotFoundError. A report with a tab or native filters first builds its notification link: _get_url -> _get_tab_url -> CreateDashboardPermalinkCommand -> security_manager.raise_for_access -> get_user_roles, which reads g.user.is_anonymous on None. _raise_for_executor_dashboard_access returned early for a missing user, so nothing converted this into the executor error, and the failure-notification path (_get_failure_notification_url, used by send_error) built the same link and crashed too, so no email was sent.

Changes (all in superset/commands/report/execute.py; get_user_roles in the security manager is untouched):

  • _raise_for_executor_dashboard_access gets a require_executor flag. With no user, when a permalink is about to be created (_get_tab_url passes True), an unresolved executor now raises ReportScheduleExecutorNotFoundError, the same error and handling as a plain report (not retried, owner notified). The early return for an anonymous user is unchanged.
  • _get_failure_notification_url builds the stateful link as the resolved executor (via override_user) when there is no user and the report has a dashboard. This covers terminal-error handling that runs outside the executor's user context. If the executor is missing or lacks access, it falls back to the plain dashboard link so the owner still gets the email. Chart reports keep their existing behaviour.

TESTING INSTRUCTIONS

pytest tests/unit_tests/commands/report/execute_test.py \
       tests/unit_tests/commands/report/executor_test.py
  • get_dashboard_urls for a report with a tab / native filters and an unresolved executor raises ReportScheduleExecutorNotFoundError instead of AttributeError.
  • _get_failure_notification_url falls back to the plain dashboard link when the executor is missing, and builds the stateful link as the executor when it is valid but no user is set.
  • A state-level test runs ReportNotTriggeredErrorState.next for tab, filters, plain-dashboard and chart reports with a missing executor and asserts an ERROR log row, exactly one failure notification, no retry (even with retry_on_failure), and the expected link.
  • Anonymous-user behaviour is unchanged.

Five of the new tests fail on master. The others guard unchanged behaviour (plain dashboard and chart reports, anonymous users, no retry).

Test limitation: the state-level test drives ReportNotTriggeredErrorState.next rather than ReportScheduleStateMachine.run, which is wrapped in a transaction.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: ALERT_REPORTS_FILTER, ALERT_REPORT_TABS
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

eschutho and others added 2 commits November 7, 2026 00:54
…utor

A dashboard report with tabs or native filters and no resolvable executor
crashed with an AttributeError while building the permalink (g.user was
None), so the failure notification was never sent. Raise
ReportScheduleExecutorNotFoundError instead, build failure-notification
links as the resolved executor, and fall back to the plain dashboard URL
when the executor is missing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…issing

The failure-link fallback resolved an executor for every report with no
user context, so a chart report with a missing executor hit a missing
dashboard in the plain-dashboard fallback and sent no failure email. Only
dashboard reports now take that path; chart reports use the explore link
as before. Adds state-level coverage for tab, native-filter, plain
dashboard and chart reports.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.41%. Comparing base (ca881ce) to head (dfcb9ef).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46063      +/-   ##
==========================================
- Coverage   85.88%   85.41%   -0.47%     
==========================================
  Files        3119     3096      -23     
  Lines      216108   213608    -2500     
  Branches    51254    50104    -1150     
==========================================
- Hits       185595   182461    -3134     
- Misses      27099    27733     +634     
  Partials     3414     3414              
Flag Coverage Δ
hive 33.95% <8.33%> (-0.01%) ⬇️
mysql 51.59% <25.00%> (-0.01%) ⬇️
postgres 51.63% <25.00%> (-0.01%) ⬇️
presto 35.63% <8.33%> (-0.01%) ⬇️
python 88.37% <100.00%> (+<0.01%) ⬆️
sqlite 51.30% <25.00%> (-0.01%) ⬇️
unit 83.75% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sadpandajoe
sadpandajoe marked this pull request as ready for review November 12, 2026 22:46
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: dfcb9ef8fa11

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @eschutho, thanks for this fix! LGTM. I ran the missing, inactive, no-access and anonymous executor cases against the real permalink command and each one lands where the description says, and the new tests fail without the change as described.

One heads-up, not a blocker: #45463 adds tests/unit_tests/commands/report/test_native_filter_urls.py, which calls get_dashboard_urls() with no user and no executor patch. It passes on master and fails with ReportScheduleExecutorNotFoundError once this change is applied, so whichever of the two lands second will need a resolvable executor in that test.

All the test lanes are green; the unit-tests-required gate was still pending when I looked.

@sadpandajoe
sadpandajoe merged commit 921dd08 into master Nov 21, 2026
79 of 81 checks passed
@sadpandajoe
sadpandajoe deleted the fix-report-no-executor-tab-filter-crash branch November 21, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants