Vamsi-klu opened a new pull request, #72241:
URL: https://github.com/apache/airflow/pull/72241
## What is the change?
`CloudComposerExternalTaskSensor` and `CloudComposerExternalTaskTrigger` now
succeed only when at least one task instance falls inside `execution_range` and
every in-window instance is in the requested states. An empty window means keep
waiting, not success, failed, or skipped.
## Why did I do it?
closes: #67051
related: #67052
The old window check returned True whenever it saw no in-window TI in a
disallowed state. A non-empty API response whose TIs all sit outside the window
is vacuously True, so the sensor went green and downstream MERGE/load ran
against data that never showed up. The same hole fires `failed_states` and
`skipped_states` for a window that contained nothing.
#67052 is the Dag-run sibling and stays Dag-run only. This PR is the
task-instance class.
## How did I do it?
Both copies of `_check_task_instances_states` now partition TIs with the
existing exclusive timestamp test (`start < ts < end`), return False when the
in-window set is empty, and otherwise require every in-window TI to be in
`states`. Airflow 2 `execution_date` and Airflow 3 `logical_date` keys are
unchanged. I did not extract a shared helper with #67052, did not touch
`_check_dag_runs_states`, and did not switch the bounds to inclusive.
## What's the impact?
No more false success, fail, or skip from out-of-window-only TI lists. Users
who relied on the old empty-window success should set a finite `timeout`,
because an empty window now waits. Existing in-window behaviour is unchanged.
## What's the test plan?
New unit tests in `test_cloud_composer.py` (sensor and trigger):
- all TIs outside the window keep waiting (AF2 and AF3)
- mixed window uses only in-window states
- `failed_states` / `skipped_states` do not fire when the window is empty
- timestamps equal to `start_date` or `end_date` stay excluded
- deferrable trigger sleeps and does not yield success/failed/skipped on the
first poll, then succeeds when an in-window TI appears
I reverted the production change and re-ran the new tests: 16 failed for the
right reason (vacuous True / failed / skipped). The mixed-window tests still
passed, as they should: old code already ignored out-of-window TIs when any TI
was inside the window.
```
uv run --project providers/google pytest \
providers/google/tests/unit/google/cloud/sensors/test_cloud_composer.py \
providers/google/tests/unit/google/cloud/triggers/test_cloud_composer.py \
-xvs
```
58 passed. Ruff format/check on the four files: clean. Live Composer was not
run; it needs real GCP infrastructure.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Grok 4.6
Generated-by: Grok 4.6 following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
Drafted-by: Grok 4.6 (no human review before posting)
--
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]