bingqin2 opened a new pull request, #73086: URL: https://github.com/apache/airflow/pull/73086
`_get_group_tasks`, which backs the `task_group_id` filter of `GET /execution/task-instances/count` and `GET /execution/task-instances/states`, resolves the task group against the latest Dag version, even when the request names the runs it is asking about. For a run of a versioned bundle that is the wrong version whenever the group changed after the run was created: a group renamed or removed since answers 404 although the run has its task instances, and a group that only exists in the newer version is reported as part of the run although it is not. `ExternalTaskSensor` and `WorkflowTrigger` poll these endpoints with `logical_dates` / `run_ids`, and the task-group existence check being added for #72514 relies on the answer being about the named runs. This resolves the group against the Dag version each named run resolves to, through `DBDagBag.get_dag_for_run`: the version a run of a versioned bundle was created from, the latest version for every other run, which is also how the scheduler treats those runs when it re-verifies them. One lookup is made per distinct version among the named runs. Without a named run, or while none of the named runs exists yet, the latest version answers as before, so the existing behaviour and tests are unchanged. The task-instance query, the `(task_id, map_index)` handling in the count endpoint and the 404 payload are untouched, so there is no execution API version change. **Changes** - `airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py`: `_get_group_task_ids` resolves the group per named run; `_get_group_tasks` uses it - `airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py`: `test_get_count_task_group_resolved_against_run_version` and `test_get_task_states_task_group_resolved_against_run_version` (a pinned run keeps its group after a rename in the next version; the new group is not part of it; without a named run the latest version still answers). Both fail on main. **Testing** - `airflow-core`: `tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py` (whole file) - mypy on the changed module, prek hooks on the changed files related: #72514 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Claude Fable 5.1) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions). I reviewed and understand all changes; the tests were run locally as listed above. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
