Repository navigation
fix(reports): fail cleanly and notify the owner when a tab/filter report has no valid executor - #46063
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gabotorresruiz
left a comment
There was a problem hiding this comment.
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.
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_userreturns(None, None)and the run proceeds withg.userunset. A plain report fails later, in the screenshot step, withReportScheduleExecutorNotFoundError. 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 readsg.user.is_anonymousonNone._raise_for_executor_dashboard_accessreturned early for a missing user, so nothing converted this into the executor error, and the failure-notification path (_get_failure_notification_url, used bysend_error) built the same link and crashed too, so no email was sent.Changes (all in
superset/commands/report/execute.py;get_user_rolesin the security manager is untouched):_raise_for_executor_dashboard_accessgets arequire_executorflag. With no user, when a permalink is about to be created (_get_tab_urlpassesTrue), an unresolved executor now raisesReportScheduleExecutorNotFoundError, 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_urlbuilds the stateful link as the resolved executor (viaoverride_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
get_dashboard_urlsfor a report with a tab / native filters and an unresolved executor raisesReportScheduleExecutorNotFoundErrorinstead ofAttributeError._get_failure_notification_urlfalls 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.ReportNotTriggeredErrorState.nextfor tab, filters, plain-dashboard and chart reports with a missing executor and asserts an ERROR log row, exactly one failure notification, no retry (even withretry_on_failure), and the expected link.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.nextrather thanReportScheduleStateMachine.run, which is wrapped in a transaction.ADDITIONAL INFORMATION
ALERT_REPORTS_FILTER,ALERT_REPORT_TABS🤖 Generated with Claude Code