Skip to content

fix: restore Airflow 2 Task Instances view semantics for mark-success#67790

Open
anmolxlight wants to merge 3 commits into
apache:mainfrom
anmolxlight:fix/issue-67707-task-instances-mark-success-downstream-clearing
Open

fix: restore Airflow 2 Task Instances view semantics for mark-success#67790
anmolxlight wants to merge 3 commits into
apache:mainfrom
anmolxlight:fix/issue-67707-task-instances-mark-success-downstream-clearing

Conversation

@anmolxlight
Copy link
Copy Markdown
Contributor

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

  • Code changes
  • Tests updated
  • No new imports required

@anmolxlight anmolxlight force-pushed the fix/issue-67707-task-instances-mark-success-downstream-clearing branch from 6b35d9b to a4bd9f9 Compare May 31, 2026 12:08
anmolxlight and others added 2 commits June 1, 2026 08:24
- dag.py: pass downstream=False to mark_tasks.set_state so it only mutates
  the targeted TIs; let the explicit 'if downstream:' block own downstream
  handling. Fixes both set_task_instance_state and set_task_group_state.
- dag.py: apply ruff-format break on the long line in the clear path.
- test_dag.py: add @pytest.mark.need_serialized_dag and the run_id parametrize
  to test_set_task_instance_state_downstream_clears_failed (was missing
  run_id fixture).
- test_dag.py: drop the 'downstream=True' addition from
  test_set_task_instance_state_mapped and assert downstream stays FAILED
  (the test exercises the new 'do not clear downstream by default' behavior).

Resolves the 9 CI check failures on PR apache#67790:
- CI image checks / Static checks (ruff-format)
- Postgres/MySQL/Sqlite tests (both Core..Serialization and API..CLI)
- Low dep tests (both groups)
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.

Task Instances view mark-success behavior differs from Airflow 2 and resumes downstream tasks

2 participants