Skip to content

Fix dag run clear existing tasks#65628

Merged
bbovenzi merged 2 commits into
apache:mainfrom
astronomer:fix-clear-run
Apr 23, 2026
Merged

Fix dag run clear existing tasks#65628
bbovenzi merged 2 commits into
apache:mainfrom
astronomer:fix-clear-run

Conversation

@bbovenzi
Copy link
Copy Markdown
Contributor

Clearing a Dag run with "Only existing tasks" or "Only failed tasks" was not working in the UI because the dry_run request to the api_server was erroring out with serialization failures.

Also fixed an issue where the dry run for "Only new tasks" could return a result to clear even if the task already existed.

Before:
Screenshot 2026-04-21 at 4 40 08 PM

After:
Screenshot 2026-04-21 at 4 38 43 PM


Was generative AI tooling used to co-author this PR?
  • Yes Claude Sonnet 4.6

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. labels Apr 21, 2026
@bbovenzi bbovenzi requested a review from Copilot April 21, 2026 20:52
@bbovenzi bbovenzi added this to the Airflow 3.2.2 milestone Apr 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the “clear DAG run” dry-run behavior used by the UI by ensuring the API returns serializable TaskInstance data (with required relationships loaded) and correct “only new tasks” results.

Changes:

  • Update /dagRuns/{dag_run_id}/clear dry-run to query TaskInstances with proper eager-loading (and implement “only_new” via TI existence checks).
  • Add regression/integration tests covering full TaskInstanceResponse serialization and “only_failed” / “only_new” behaviors.
  • Adjust the UI tasks table to hide the row-count heading inside the action accordion.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py Reworks dry-run clear logic to avoid serialization failures and to compute “only_new” based on existing TIs.
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py Adds regression + integration tests for dry-run serialization and “only_new” behavior across DAG versions.
airflow-core/src/airflow/ui/src/components/ActionAccordion/ActionAccordion.tsx Hides DataTable row-count heading in the affected-tasks table.

Comment thread airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py Outdated
Remove the two mocked only_new dry-run tests that patched SerializedDAG.clear
and asserted it was called — the dry-run path no longer calls dag.clear() for
only_new=True (it queries the DB directly for TI existence instead).

Replace with a real DB-backed test: since DAG1_RUN1_ID already has TIs for all
tasks in the latest DAG version, the endpoint correctly returns 0 new tasks.

Also fix test_only_new_skips_task_that_already_has_ti to create the task_b TI
via the non-dry-run API endpoint instead of constructing a bare TaskInstance
object, which requires a task Operator and dag_version_id and would fail.
@bbovenzi bbovenzi added the backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch label Apr 23, 2026
@bbovenzi bbovenzi merged commit 504694e into apache:main Apr 23, 2026
138 of 139 checks passed
@bbovenzi bbovenzi deleted the fix-clear-run branch April 23, 2026 18:28
@github-actions
Copy link
Copy Markdown
Contributor

Backport failed to create: v3-2-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 504694e v3-2-test

This should apply the commit to the v3-2-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

@vatsrahul1001
Copy link
Copy Markdown
Contributor

@bbovenzi can you help with backport PR?

@bbovenzi bbovenzi mentioned this pull request May 15, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants