nathadfield opened a new pull request, #67273:
URL: https://github.com/apache/airflow/pull/67273

   ## Motivation
   
   PR #63884 introduced a 4-tier `rerun_with_latest_version` config hierarchy
   (explicit > DAG-level > global config > fallback) controlling whether
   clearing/rerunning a Dag run uses the latest bundle version. That hierarchy
   is wired into the UI clear dialogs, the public clear/backfill API endpoints,
   and the `airflow backfill create` CLI command — but **not** into
   `TriggerDagRunOperator`'s `reset_dag_run=True` path.
   
   When `TriggerDagRunOperator(reset_dag_run=True)` is invoked and the target
   Dag run already exists, the task SDK trigger client gets a 409 and falls
   back to `client.clear(dag_id, run_id)`. That hits
   `POST /execution/dag-runs/{dag_id}/{run_id}/clear` on the execution API,
   which previously called `dag.clear(run_id=run_id)` with no
   `run_on_latest_version` argument. As a result, the global and DAG-level
   `rerun_with_latest_version` config had no effect on operator-driven reruns.
   
   ## What this PR does
   
   Wires the existing `resolve_run_on_latest_version` resolver into the
   execution-API `clear_dag_run` endpoint, so operator-driven reruns honor
   the same hierarchy as UI-, API-, and CLI-driven reruns.
   
   ```python
   resolved_run_on_latest = resolve_run_on_latest_version(None, dag_id, session)
   dag.clear(run_id=run_id, run_on_latest_version=resolved_run_on_latest)
   ```
   
   `None` is passed as the explicit override because the operator does not
   (intentionally) accept a per-call override — the DAG-level toggle and
   global config from #63884 are already sufficient, and adding an operator
   parameter that accepts arbitrary versions would create a security gap (a
   git bundle could be made to run a commit that was never on the tracking
   branch).
   
   Brand-new Dag runs from `TriggerDagRunOperator` are unaffected: they
   already use the latest bundle version because `_create_orm_dagrun` reads
   `DagModel.bundle_version` at trigger time. Only the rerun/clear path
   needed wiring.
   
   No payload/schema change; no client change; no Cadwyn version bump.
   
   ## Test plan
   
   - [x] New unit test `test_dag_run_clear_invokes_resolver` verifies the
         resolver is invoked with `None` as the explicit override.
   - [x] Existing `TestDagRunClear` tests still pass unchanged.
   - [x] `prek run --from-ref apache/main --stage pre-commit` — all hooks pass
         (ruff, mypy-airflow-core, etc.).
   
   closes: #60880
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.7)
   
   Generated-by: Claude Code (Opus 4.7) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
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]

Reply via email to