steveahnahn opened a new pull request, #69786:
URL: https://github.com/apache/airflow/pull/69786

   ### 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 #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**.
   
   <img width="900" alt="control run on main marked Success on a cancelled job; 
fixed run marked Failed" 
src="https://raw.githubusercontent.com/steveahnahn/airflow/pr-screenshots/airbyte_cancel_control_vs_fixed.jpeg";
 />
   
   ### 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?
   
   - [X] Yes, Claude Code (Fable 5)
   
   Generated-by: Claude Code (Fable 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to