Skip to content

Fix AirbyteJobSensor marking a cancelled job as success in deferrable mode#69786

Open
steveahnahn wants to merge 1 commit into
apache:mainfrom
steveahnahn:fix-airbyte-job-sensor-cancelled-deferred
Open

Fix AirbyteJobSensor marking a cancelled job as success in deferrable mode#69786
steveahnahn wants to merge 1 commit into
apache:mainfrom
steveahnahn:fix-airbyte-job-sensor-cancelled-deferred

Conversation

@steveahnahn

Copy link
Copy Markdown
Contributor

Problem

  • AirbyteJobSensor in deferrable mode resumes via execute_complete, which only fails on an error event.
  • A job cancelled while the sensor is deferred makes AirbyteSyncTrigger yield a cancelled event, which fell through to the success path: the task is marked SUCCESS and downstream tasks run against a sync that never completed.
  • The same sensor fails correctly on a cancelled job in every other path: non-deferrable poke() raises, the deferrable execute() raises when it sees CANCELLED before deferring, and the sibling AirbyteTriggerSyncOperator.execute_complete already fails on the cancelled event (added in Implement execution_timeout semantics for AirbyteTriggerSyncOperator in deferrable mode #64051, which did not cover the sensor).

Change

  • Fail on any non-success event in the sensor's execute_complete, matching poke(). The cancelled event now fails the task, and unrecognized statuses fail closed instead of being treated as success.

Live verification

Ran a real airflow standalone (scheduler, triggerer, API server) against a live local endpoint serving the Airbyte jobs API, with the connection host pointed at it. Both runs: sensor deferred while the job was running, then the job was flipped to cancelled.

  • Control run on current main: trigger yielded the cancelled event, task log shows "completed successfully.", run marked Success.
  • Same scenario with this fix: task fails with RuntimeError: Job run 1 has been cancelled., run marked Failed.

control run on main marked Success on a cancelled job; fixed run marked Failed

Tests

  • test_execute_complete_fails_when_job_did_not_succeed (parametrized: cancelled, unrecognized status) fails on the code before this change; the failure output shows the bug verbatim ("completed successfully." on a cancelled event).
  • test_execute_complete_succeeds_on_success_event guards the happy path.

Was generative AI tooling used to co-author this PR?
  • Yes, Claude Code (Fable 5)

Generated-by: Claude Code (Fable 5) following the guidelines

… mode

When the deferred sensor resumes, execute_complete only failed on an "error"
event. A job cancelled while the sensor was deferred yields a "cancelled"
event, which fell through to the success path, so the task was marked SUCCESS
and downstream tasks ran against a sync that never completed. The same sensor
fails correctly on a cancelled job in non-deferrable mode, and the sibling
AirbyteTriggerSyncOperator already fails on the cancelled event, so deferrable
sensor runs silently diverged from both. Fail closed on any non-success status
so unrecognized statuses cannot be treated as success either.
@steveahnahn steveahnahn marked this pull request as ready for review July 12, 2026 20:31
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.

1 participant