fix: restore Airflow 2 Task Instances view semantics for mark-success#67790
Open
anmolxlight wants to merge 3 commits into
Open
Conversation
6b35d9b to
a4bd9f9
Compare
Pedrinhonitz
suggested changes
Jun 1, 2026
Contributor
Pedrinhonitz
left a comment
There was a problem hiding this comment.
Please ensure that all quality tests are successful.
- Tests (AMD) / CI image checks / Static checks (pull_request)
- Tests (AMD) / Low dep tests:core / All-core:LowestDeps:14:3.10:API...CLI (pull_request)
- Tests (AMD) / Low dep tests:core / All-core:LowestDeps:14:3.10:Core...Serialization (pull_request)
- Tests (AMD) / MySQL tests: core / DB-core:MySQL:8.0:3.10:API...CLI (pull_request)
- Tests (AMD) / MySQL tests: core / DB-core:MySQL:8.0:3.10:Core...Serialization (pull_request)
- Tests (AMD) / Postgres tests: core / DB-core:Postgres:14:3.10:API...CLI (pull_request)
- Tests (AMD) / Postgres tests: core / DB-core:Postgres:14:3.10:Core...Serialization (pull_request)
- Tests (AMD) / Sqlite tests: core / DB-core:Sqlite:3.10:API...CLI (pull_request)
- Tests (AMD) / Sqlite tests: core / DB-core:Sqlite:3.10:Core...Serialization (pull_request)
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inupstream_failedorfailedstate.Airflow 3's
dag.set_task_instance_state()unconditionally cleared downstream failed/upstream_failedtasks after setting state, even whendownstream=Falsewas 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
downstreamparameter in bothset_task_instance_state()andset_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_failedtasks 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 inif downstream:set_task_group_state(): Same treatment for consistencyairflow-core/tests/unit/models/test_dag.py:test_set_task_instance_state: Updated to expect no clearing withdownstream=False(default)test_set_task_instance_state_downstream_clears_failed: Verifies clearing withdownstream=Truetest_set_task_instance_state_mapped: Updated to passdownstream=Truesince it expects clearingBackward compatibility
Checklist