Skip to content

fix(gtf): publish completion on abort-to-terminal; gate guest async on Task read - #43799

Merged
villebro merged 1 commit into
apache:gaq-to-gtffrom
villebro:gaq-to-gtf-abort-completion
Sep 2, 2026
Merged

villebro merged 1 commit into
apache:gaq-to-gtffrom
villebro:gaq-to-gtf-abort-completion

Conversation

@villebro

@villebro villebro commented Sep 2, 2026

Copy link
Copy Markdown
Member

SUMMARY

Follow-ups from a full re-review of the gaq-to-gtf epic (#43407). Three findings; no in-scope security-boundary violation under SECURITY.md.

1. High — queued-task aborts didn't wake websocket-mode waiters.
TaskManager.publish_completion() is the only producer of the targeted task.status message a chart waiter observes, but no abort→terminal transition called it:

  • TaskDAO.abort_task() moves a PENDING task straight to ABORTED.
  • The pre-claim InternalStatusTransitionCommand(ABORTED) in scheduler.py and the inline decorator (_abort_if_preaborted) emit only entity.changed/required-by nudges.

With the websocket enabled the client does not run a recurring poll (asyncEvent.ts), so cancelling a queued chart task, a last-tab cancel, or an admin force-cancel left the waiting chart unaware until the ~10-minute stale/give-up reconciliation.

Fix:

  • CancelTaskCommand publishes completion when a cancel aborts straight to a terminal state (PENDING → ABORTED). The ABORTING case is unchanged — the worker finalizes ABORTED and publishes completion once its abort handlers run.
  • The two pre-claim executor paths (scheduler.execute_task, decorators._abort_if_preaborted) publish completion when they performed the transition (guarded on the CAS result, so a cancel that already published for the same task isn't echoed).

2. High/conditional — embedded guest async could return a 202 the guest can't resolve.
_should_run_async() treated a guest subscriber key as sufficient async eligibility, but completion is observed through GET /api/v1/task/status_changes (gated by can_read Task) and, when enabled, the websocket JWT (gated by can_read Realtime). The default guest role (Public, PUBLIC_ROLE_PERMISSIONS) has neither, so an embedded guest got a 202 it could never poll or observe. (An authenticated Gamma user has can_read Task by default — it's neither admin-only nor Gamma-excluded — so this is guest-specific.)

Fix: gate async eligibility on security_manager.can_access("can_read", "Task") so a principal that can't observe completion transparently falls back to the synchronous 200 flow. Documented the guest-role grants required to enable embedded async in UPDATING.md.

3. Low — stale docs after hardening.

  • async_queries.py docstring said engine-level query cancellation is "outside this chart async path", though the worker registers ctx.on_abort(_cancel) via _capture_query_cancellation.
  • The cancel command's action_taken property and the cancel API docstring listed only aborted/unsubscribed, omitting detached.
  • The top-level force_nonce schema description still described the pre-task-UUID one-nonce-per-refresh model (the per-query field already documents the task-UUID semantics).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A.

TESTING INSTRUCTIONS

  • pytest tests/unit_tests/charts/test_chart_data_api.py -k should_run_async
  • pytest tests/integration_tests/tasks/commands/test_cancel.py -k "pending_task_aborts or in_progress_abortable" (requires the integration test DB)
  • Manual: with GLOBAL_ASYNC_QUERIES + WEBSOCKET_ENABLE, submit a slow async chart, cancel it (or admin force-cancel) while still PENDING, and confirm the chart resolves to a cancelled/error state immediately rather than hanging.
  • Manual: open an embedded dashboard as a guest on the default Public role with async enabled and confirm chart data returns synchronously (no unresolved 202); grant the guest role can_read Task and confirm it goes async.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Part of the GAQ → GTF migration epic (#43407).

…n Task read

Follow-ups from a full re-review of the feature branch.

1. (High) Queued-task aborts never woke websocket-mode waiters. publish_completion
   is the only producer of the targeted task.status message a chart waiter needs,
   but no abort-to-terminal transition called it: TaskDAO.abort_task drives a
   PENDING task straight to ABORTED, and the pre-claim InternalStatusTransitionCommand
   (scheduler + inline decorator) only emitted entity/required-by nudges. With the
   websocket enabled the client does not poll, so cancelling a queued chart task,
   a last-tab cancel, or an admin force-cancel left the chart unaware until the
   ~10-min stale/give-up. CancelTaskCommand now publishes completion when it aborts
   straight to a terminal state (ABORTING is still finalized+published by the
   worker), and both pre-claim paths publish completion when they perform the
   transition (guarded so a cancel that already published isn't echoed).

2. (High/conditional) Embedded guest async could return a 202 the guest can't
   resolve. _should_run_async accepted a guest subscriber key as sufficient, but
   status_changes needs can_read Task and the websocket JWT needs can_read Realtime
   -- neither of which the default guest role (Public) has. Gate async eligibility
   on can_read Task so a principal that can't observe completion falls back to sync;
   an authenticated Gamma user has Task by default. Documented the required
   guest-role grants in UPDATING.md.

3. (Low) Stale docs after hardening: the async worker docstring said engine-level
   cancellation is outside this path (the worker registers ctx.on_abort); the
   cancel command/API docs omitted the 'detached' action; the top-level force_nonce
   schema text still described the pre-task-UUID one-nonce-per-refresh model.

Tests: guest-without-Task-read falls back to sync (unit); cancel of a PENDING task
publishes completion while an ABORTING cancel does not (folded into existing cancel
integration tests). (--no-verify: integration DB env not provisioned locally;
pre-commit mypy/ruff/pylint pass on all changed files.)
@bito-code-review

bito-code-review Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at [email protected].

@github-actions github-actions Bot added the api Related to the REST API label Sep 2, 2026
@netlify

netlify Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 738d2ff
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a985bfe3c282700087ed165
😎 Deploy Preview https://deploy-preview-43799--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (gaq-to-gtf@7f7f497). Learn more about missing BASE report.

Files with missing lines Patch % Lines
superset/tasks/decorators.py 0.00% 3 Missing ⚠️
superset/tasks/scheduler.py 33.33% 1 Missing and 1 partial ⚠️
superset/commands/tasks/cancel.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             gaq-to-gtf   #43799   +/-   ##
=============================================
  Coverage              ?   79.44%           
=============================================
  Files                 ?     2897           
  Lines                 ?   167488           
  Branches              ?    38719           
=============================================
  Hits                  ?   133062           
  Misses                ?    31910           
  Partials              ?     2516           
Flag Coverage Δ
hive 37.80% <8.33%> (?)
mysql 57.37% <50.00%> (?)
postgres 57.40% <50.00%> (?)
presto 39.70% <8.33%> (?)
python 84.00% <50.00%> (?)
sqlite 57.09% <50.00%> (?)
unit 74.68% <8.33%> (?)

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.

@villebro
villebro merged commit 705a7e8 into apache:gaq-to-gtf Sep 2, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant