Skip to content

Commit 38d3d4f

Browse files
committed
Require dag_id arg for dags list-runs (#26357)
While it would ideal to transition to a positional arg like was attempted in #25978, this unfortunately does result in a breaking change so we cannot do it now. By instead marking the existing arg as required, we maintain backcompat while also providing a helpful error message to the user if they forget it. This reverts commit ed6ea72. (cherry picked from commit f6c579c)
1 parent 0967259 commit 38d3d4f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

airflow/cli/cli_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ def string_lower_type(val):
263263
)
264264

265265
# list_dag_runs
266+
ARG_DAG_ID_REQ_FLAG = Arg(
267+
("-d", "--dag-id"), required=True, help="The id of the dag"
268+
) # TODO: convert this to a positional arg in Airflow 3
266269
ARG_NO_BACKFILL = Arg(
267270
("--no-backfill",), help="filter all the backfill dagruns given the dag id", action="store_true"
268271
)
@@ -1008,7 +1011,7 @@ class GroupCommand(NamedTuple):
10081011
),
10091012
func=lazy_load_command('airflow.cli.commands.dag_command.dag_list_dag_runs'),
10101013
args=(
1011-
ARG_DAG_ID,
1014+
ARG_DAG_ID_REQ_FLAG,
10121015
ARG_NO_BACKFILL,
10131016
ARG_STATE,
10141017
ARG_OUTPUT,

tests/cli/commands/test_dag_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,13 @@ def test_cli_list_dag_runs(self):
499499
[
500500
'dags',
501501
'list-runs',
502+
'--dag-id',
503+
'example_bash_operator',
502504
'--no-backfill',
503505
'--start-date',
504506
DEFAULT_DATE.isoformat(),
505507
'--end-date',
506508
timezone.make_aware(datetime.max).isoformat(),
507-
'example_bash_operator',
508509
]
509510
)
510511
dag_command.dag_list_dag_runs(args)

0 commit comments

Comments
 (0)