Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow-core/src/airflow/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def string_lower_type(val):

# list_jobs
ARG_DAG_ID_OPT = Arg(("-d", "--dag-id"), help="The id of the dag")
ARG_LIMIT = Arg(("--limit",), help="Return a limited number of records")
ARG_LIMIT = Arg(("--limit",), type=positive_int(allow_zero=True), help="Return a limited number of records")
job_states = tuple(state.value for state in JobState)
ARG_JOB_STATE = Arg(
("--state",),
Expand Down
9 changes: 9 additions & 0 deletions airflow-core/tests/unit/cli/test_cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,15 @@ def test_pools_set_and_delete_reject_output_flag(self, argv):
assert e.value.code == 2
assert "unrecognized arguments: --output json" in stderr.getvalue()

@pytest.mark.parametrize("bad_value", ["abc", "-1"])
def test_dags_list_jobs_rejects_invalid_limit(self, bad_value):
with contextlib.redirect_stderr(StringIO()) as stderr:
parser = cli_parser.get_parser()
with pytest.raises(SystemExit) as e:
parser.parse_args(["dags", "list-jobs", "--limit", bad_value])
assert e.value.code == 2
assert f"argument --limit: invalid positive int value: '{bad_value}'" in stderr.getvalue()

@pytest.mark.parametrize(
"action_cmd",
[
Expand Down