anmolxlight opened a new pull request, #67790:
URL: https://github.com/apache/airflow/pull/67790
## Description
Fixes #67707
In Airflow 2, marking a task as success from the **Task Instances view**
(Browse → Task Instances) used `ti.set_state()` directly — it only changed the
selected task instance's state and did **not** clear or resume downstream tasks
that were in `upstream_failed` or `failed` state.
Airflow 3's `dag.set_task_instance_state()` unconditionally cleared
downstream failed/`upstream_failed` tasks after setting state, even when
`downstream=False` was passed. This broke backward compatibility for users
migrating from Airflow 2 who relied on the Task Instances view preserving
downstream task state.
## Changes
This change gates the downstream clearing behavior behind the `downstream`
parameter in both `set_task_instance_state()` and `set_task_group_state()`:
- **`downstream=False` (default)**: Only the target TI state is changed — no
downstream clearing. This restores the Airflow 2 Task Instances view semantics.
- **`downstream=True`**: Downstream failed/`upstream_failed` tasks are also
cleared and can resume. This preserves the existing Airflow 3 DAG/Grid view
behavior.
### Files changed
- **`airflow-core/src/airflow/serialization/definitions/dag.py`**:
- `set_task_instance_state()`: Wrap downstream clearing in `if downstream:`
- `set_task_group_state()`: Same treatment for consistency
- **`airflow-core/tests/unit/models/test_dag.py`**:
- `test_set_task_instance_state`: Updated to expect no clearing with
`downstream=False` (default)
- New `test_set_task_instance_state_downstream_clears_failed`: Verifies
clearing with `downstream=True`
- `test_set_task_instance_state_mapped`: Updated to pass `downstream=True`
since it expects clearing
## Backward compatibility
- Users who mark task instances as success **without** selecting
"downstream" in the dialog get the old Airflow 2 behavior (no downstream
clearing).
- Users who explicitly select "downstream" get the downstream clearing
behavior.
- The DAG/Grid view's existing behavior is preserved.
## Checklist
- [x] Code changes
- [x] Tests updated
- [x] No new imports required
--
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]