You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "rjgoyln (via GitHub)" <gi...@apache.org> on 2026/08/01 13:05:00 UTC
[PR] Deduplicate the Dag run lookup in airflowctl dag and task commands [airflow]
rjgoyln opened a new pull request, #70904:
URL: https://github.com/apache/airflow/pull/70904
The `dags` and `tasks` commands each carried their own copy of the same logical-date Dag run lookup — near line-for-line identical, differing only in whether they returned the run or just its ID — and each repeated the same run-selector guard in front of it:
```python
if (args.run_id is None) == (args.logical_date is None):
rich.print("[red]Provide either run_id or --logical-date, but not both[/red]")
sys.exit(1)
```
Both now live in `airflowctl/ctl/utils/dag_run.py`, so the selector handling sits in one place rather than in front of every command that accepts one.
### Why two resolvers rather than one
`task_command` must *not* fetch the Dag run when a `run_id` is supplied. Doing so would add an HTTP request that did not previously happen, and would re-attribute a 404 from `Task instance … not found` to `Dag run … not found`. So `resolve_dag_run_id` takes a supplied `run_id` at face value, while `resolve_dag_run` — used by `dags state`, which needs the response body either way — fetches it. The two share the selector guard and the logical-date lookup, so no duplication survives the split.
The two added assertions pin that invariant down. Without them, a future "these two look the same, merge them" cleanup would silently add a request and swap the error message.
### Notes
- No behaviour change is intended anywhere; error strings and exit paths are unchanged.
- No newsfragment: `airflow-ctl` release managers regenerate the changelog from `git log`.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 5)
Generated-by: Claude Code (Opus 5) 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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Share airflowctl's Dag run lookup without a new request for run_id [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #70904:
URL: https://github.com/apache/airflow/pull/70904
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Share airflowctl's Dag run lookup without a new request for run_id [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #70904:
URL: https://github.com/apache/airflow/pull/70904#issuecomment-5785780912
### Backport failed to create: airflow-ctl/v0-1-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/35795795111'> Run details </a>
Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
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](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>❌</td>
<td>airflow-ctl/v0-1-test</td>
<td><a href="https://github.com/apache/airflow/commit/6e48e0fb2ba4743dfc478186eb17205f369c3ab0"><img src='https://img.shields.io/badge/Commit-6e48e0f-red' alt='Commit Link'></a></td>
</tr>
</table>
You can attempt to backport this manually by running:
```bash
cherry_picker 6e48e0f airflow-ctl/v0-1-test
```
This should apply the commit to the airflow-ctl/v0-1-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:
```bash
cherry_picker --continue
```
If you don't have cherry-picker installed, see the [installation guide](https://github.com/apache/airflow/blob/main/dev/README.md#how-to-backport-pr-with-cherry-picker-cli).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Share airflowctl's Dag run lookup without a new request for run_id [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #70904:
URL: https://github.com/apache/airflow/pull/70904#issuecomment-5768114519
**Heads-up on an incoming conflict — not a review.**
`@haseebmalik18`'s #71206 adds an `airflowctl tasks state` command, and it brings a third copy of the block this PR consolidates:
```python
if (args.run_id is None) == (args.logical_date is None):
rich.print("[red]Provide either run_id or --logical-date, but not both[/red]")
sys.exit(1)
run_id = args.run_id or _find_run_id_by_logical_date(api_client, args.dag_id, args.logical_date)
```
I've approved that PR, so it will most likely land first. When it does, this one will conflict in `task_command.py`, and the resolution is small: the new `state` command's block collapses into another `resolve_dag_run_id(api_client, args)` call, next to the two in `failed_deps` and `states_for_dag_run`.
Nothing to do right now. Flagging it so the conflict isn't a surprise when it turns up, and so the extra call site reads as expected rather than as something that crept in while this was waiting.
This note is only about the overlap — I haven't left a review on this PR itself.
---
> *This message was drafted by an AI-assisted tool and confirmed by an Airflow maintainer. If anything here looks wrong, please reply on the PR and a maintainer will follow up.*
---
Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org