Skip to content

airflowctl dagrun list crashes unless both --state and --limit are explicitly provided #65725

Description

@srchilukoori

Airflow CTL Version

0.1.4rc2 (latest stable)

Airflow CTL Command

airflowctl dagrun list

Keyring Backend / Version

Keyring Backend/Headless

Auth Type

Token

What is the current behaviour?

airflowctl dagrun list fails unless both--state and --limit are passed explicitly. Two separate errors surface depending on which flag is missing:

Bug 1 — missing --state sends literal "None" to the API

Any invocation without --state crashes:

$ airflowctl dagrun list
Server error: Invalid value for state. Valid values are queued, running, success, failed
$ airflowctl dagrun list --limit 5
Server error: Invalid value for state. Valid values are queued, running, success, failed
$ airflowctl dagrun list --dag-id my_dag
Server error: Invalid value for state. Valid values are queued, running, success, failed

Root cause: DagRunOperations.list() in operations.py declares state: str (required, no default). The CLI framework passes None when --state is omitted. Line 630 evaluates str(None)"None" → sent to the API, which rejects it.

Bug 2 — missing --limit sends an empty string to the API

Any invocation with --state but without --limit crashes:

$ airflowctl dagrun list --state running
Server error: Input should be a valid integer, unable to parse string as an integer (loc: query.limit, input: '')
$ airflowctl dagrun list --state queued
Server error: Input should be a valid integer, unable to parse string as an integer (loc: query.limit, input: '')

Root cause: Same pattern — limit: int is declared with no default. The CLI framework passes None; httpx encodes None as an empty string in the query, which fails FastAPI's integer validation.

Workaround: Both --state and --limit must be provided:

airflowctl dagrun list --state running --limit 100

Test matrix:

CommandResult
dagrun list❌ state error
dagrun list --limit 5❌ state error
dagrun list --dag-id <id>❌ state error
dagrun list --state running❌ limit error
dagrun list --state queued❌ limit error
dagrun list --state running --limit 10✅ works
dagrun list --state failed --limit 3✅ works

What is the expected results?

Both --state and --limit should be optional:

  • Omitting --state should return dag runs for all states.
  • Omitting --limit should use a sensible default (e.g. 100) or the server default.

Anything else?

Proposed fix in airflowctl/api/operations.py:

# Beforedeflist(
self,
state: str,
limit: int,
...
):
params: dict[str, Any] = {
"state": str(state),
"limit": limit,
}
# Afterdeflist(
self,
state: str|None=None,
limit: int|None=None,
...
):
params: dict[str, Any] = {}
ifstateisnotNone:
params["state"] =stateiflimitisnotNone:
params["limit"] =limit

Environment: Breeze (Docker), Python 3.10, SQLite backend, httpx==0.28.1.

Generated with assistance from Claude (Anthropic). All commands run and verified manually against a live Breeze environment.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions