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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to