Skip to content

fix(reports): skip inactive owners in get_executor (#33584) - #42611

Closed
Abdulrehman-PIAIC80387 wants to merge 1 commit into
apache:masterfrom
Abdulrehman-PIAIC80387:fix/report-schedule-skip-inactive-executor-33584
Closed

fix(reports): skip inactive owners in get_executor (#33584)#42611
Abdulrehman-PIAIC80387 wants to merge 1 commit into
apache:masterfrom
Abdulrehman-PIAIC80387:fix/report-schedule-skip-inactive-executor-33584

Conversation

@Abdulrehman-PIAIC80387

Copy link
Copy Markdown
Contributor

SUMMARY

Fixes #33584.

get_executor in superset/tasks/utils.py walks the configured executor priority list (CREATOR → MODIFIER → EDITOR → …) and returns the first matching owner/creator/modifier without checking whether that user is active. When the picked user was later deactivated, their username lands in login_user() in MachineAuthProviderUser.get_auth_cookies, which silently returns False for inactive users. No session cookie is set; the downstream screenshot / CSV / dashboard-render request runs with no auth and surfaces as an opaque ReportScheduleCsvFailedError.

Per @rusackas on the issue thread, the fix is to have get_executor skip inactive owners so the priority chain falls through to an active one (or raises the existing ExecutorNotFoundError if none exist).

FIX

Adds a small _is_active(user) predicate and applies it at every direct-user return site in get_executor:

  • CREATOR, MODIFIER, both _EDITOR variants
  • EDITOR's modifier/creator/editor-users fallback chain

Intentionally left unchanged:

  • _get_indirect_editor_user — already filters on User.active.is_(True)
  • FixedExecutor / CURRENT_USER — not ab_user-backed at this layer
  • login_user(force=True) — considered and rejected: bypassing the FAB active-user check would let deactivated users execute schedules on their behalf, which is a regression, not a fix

BEHAVIOR MATRIX

Scenario Before After
Creator active uses creator ✓ uses creator ✓ (unchanged)
Creator inactive, modifier active picks creator → auth fails → ReportScheduleCsvFailedError uses modifier ✓
All owners inactive picks first inactive → auth fails → ReportScheduleCsvFailedError ExecutorNotFoundError (actionable)
Indirect (role/group) editor filtered by is_active filtered by is_active ✓ (unchanged)

TESTING INSTRUCTIONS

Manual (requires a working Alerts & Reports setup):

  1. Create a scheduled report as user A
  2. Add user B as an owner
  3. Deactivate user A (UPDATE ab_user SET active=false WHERE username='A')
  4. Trigger the schedule
  5. Before: ReportScheduleCsvFailedError in logs, no email
  6. After: report sends; the executor log line names user B

Automated:

pytest tests/unit_tests/tasks/test_utils.py::test_get_executor -v

Four new parametrized cases: inactive-creator-falls-through, all-inactive-raises, EDITOR-skips-inactive-editor-user, CREATOR_EDITOR-inactive-editor-falls-through. Existing cases stay green because the _get_users / _make_user_subject helpers now carry an explicit active flag defaulted to True.

ADDITIONAL INFORMATION

``get_executor`` in ``superset/tasks/utils.py`` walked the executor
priority list (CREATOR → MODIFIER → EDITOR → …) and returned the first
matching owner without checking ``user.active``. When the picked user
was later deactivated, their username was handed to ``login_user()`` in
``MachineAuthProviderUser.get_auth_cookies``, which silently returns
``False`` for inactive users. No session cookie was set; the downstream
screenshot / CSV / dashboard-render request failed without auth and
surfaced as an opaque ``ReportScheduleCsvFailedError``.

Fix adds a small ``_is_active(user)`` predicate and applies it at every
direct-user return site in ``get_executor`` (CREATOR, MODIFIER, both
``_EDITOR`` variants, and the EDITOR modifier/creator/editor-users
fallback). The priority chain now falls through to the next active
candidate, or raises the existing ``ExecutorNotFoundError`` when none
exist — which is far more actionable than the silent auth failure.

Left intentionally unchanged:
* The indirect (role/group) path in ``_get_indirect_editor_user``
  already filters on ``User.active.is_(True)``.
* ``FixedExecutor`` / ``CURRENT_USER`` paths are not ``ab_user``-backed
  at this layer.
* ``login_user(force=True)`` was considered and rejected: it would let
  deactivated users execute schedules on their behalf, which is a
  regression, not a fix.

Tests: extended the existing parametrized ``test_get_executor`` with
four new cases (inactive-creator-falls-through, all-inactive-raises,
EDITOR-skips-inactive-editor-user, CREATOR_EDITOR-inactive-editor-
falls-through). The ``_get_users`` / ``_make_user_subject`` helpers now
carry an explicit ``active`` flag defaulted to ``True`` so all existing
cases keep their historical "user is usable" intent.
@dosubot dosubot Bot added the alert-reports Namespace | Anything related to the Alert & Reports feature label Jul 30, 2026
@bito-code-review

bito-code-review Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #5ad4a1

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 453ff2b..453ff2b
    • superset/tasks/utils.py
    • tests/unit_tests/tasks/test_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@Abdulrehman-PIAIC80387 Abdulrehman-PIAIC80387 changed the title fix(reports): skip inactive users when resolving the report executor fix(reports): skip inactive owners in get_executor (#33584) Jul 30, 2026
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.33%. Comparing base (673f928) to head (453ff2b).

Files with missing lines Patch % Lines
superset/tasks/utils.py 63.63% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42611      +/-   ##
==========================================
- Coverage   65.33%   65.33%   -0.01%     
==========================================
  Files        2803     2803              
  Lines      158490   158493       +3     
  Branches    36178    36178              
==========================================
  Hits       103557   103557              
- Misses      52922    52924       +2     
- Partials     2011     2012       +1     
Flag Coverage Δ
hive 38.21% <9.09%> (-0.01%) ⬇️
mysql 57.63% <63.63%> (+<0.01%) ⬆️
postgres 57.67% <63.63%> (-0.01%) ⬇️
presto 40.12% <9.09%> (-0.01%) ⬇️
python 59.07% <63.63%> (-0.01%) ⬇️
sqlite 57.30% <63.63%> (+<0.01%) ⬆️
unit 100.00% <ø> (ø)

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.

@Abdulrehman-PIAIC80387

Copy link
Copy Markdown
Contributor Author

Superseded by #42612 (@rusackas independently opened the same fix). Closing to avoid duplicate triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alert-reports Namespace | Anything related to the Alert & Reports feature size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Report Schedule execution failed when user who created is not active (but current owner is active)

1 participant