Uh oh!
There was an error while loading. Please reload this page.
Share airflowctl's Dag run lookup without a new request for run_id - #70904
Open
rjgoyln wants to merge 1 commit into
Open
Share airflowctl's Dag run lookup without a new request for run_id#70904rjgoyln wants to merge 1 commit into
rjgoyln wants to merge 1 commit into
Conversation
The dags and tasks commands each carried their own copy of the same logical-date Dag run lookup, differing only in what they returned, and each repeated the run-selector guard in front of it. Sharing them lets the selector handling live in one place rather than in front of every command that accepts one. A supplied run_id is deliberately still taken at face value rather than fetched, so commands acting on a nested resource keep reporting a miss against that resource instead of against the Dag run. The added assertions pin that down, since collapsing the two resolvers would otherwise silently add a request and re-attribute the 404.
rjgoyln
marked this pull request as ready for review
August 1, 2026 15:07
rjgoyln
requested review from
bugraoz93, dheerajturaga, henry3260 and potiuk
as code ownersAugust 1, 2026 15:07
SameerMesiah97
approved these changes
Aug 1, 2026
SameerMesiah97
left a comment
Contributor
There was a problem hiding this comment.
Looks good. This is a relatively low-risk refactor,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
airflowctl tasks failed-depsandairflowctl tasks states-for-dag-runintentionally do not look up a Dag run when the user supplies arun_id; the ID is passed directly to the task-instance endpoint. That behavior was introduced in #69915 to avoid an unnecessary HTTP request, but the remaining logical-date lookup and selector validation were duplicated across commands.This PR moves the shared logic into
airflowctl/ctl/utils/dag_run.py, removing the duplication while preserving the existing request pattern and user-visible behavior.Why two resolvers?
The split is intentional.
resolve_dag_run_idreturns a suppliedrun_iddirectly, avoiding the extra Dag run lookup.resolve_dag_runfetches the Dag run because commands such asdags stateneed the full response to display fields such asstateandconf.Both helpers share the selector validation and logical-date lookup, but keep the different
run_idbehavior intact.A single parameterized resolver was considered, but since the two helpers naturally return different types (
strvsDAGRunResponse), combining them would require either a union return type or@overloaddefinitions. That adds more complexity than the small amount of dispatch logic it would eliminate.Tests
The "don't look up a supplied
run_id" behavior was previously not enforced by the test suite.As a demonstration, adding a verification-only
dag_runs.getcall (for example, to validate a suppliedrun_id) produces the following result:mainThe new assertions make this behavior an explicit contract and prevent future refactors from unintentionally adding the extra request.
Notes
airflow-ctlrelease managers regenerate the changelog fromgit log.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines