airflowctl: datetime.datetime-typed CLI parameters don't accept any value

Open Beginner friendly
#70,232 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start in airflow-ctl/src/airflowctl/ctl/cli_config.py at _python_type_from_string and reproduce the airflowctl dagrun list --start-date example. Compare the datetime.datetime mapping with the existing json_dict_type parser pattern. Done means valid ISO-8601 datetime arguments work for generated CLI commands and invalid values produce a clear argparse error.

Written by the indexing model from the issue text.

Description

area:CLI kind:bug needs-triage
Under which category would you file this issue?

Airflow Core

Apache Airflow version

airflow 3.2.2 / airflow-ctl 0.1.5 (also present on main)

What happened and how to reproduce it?

airflowctl dagrun list (and any other auto-generated CLI command with a datetime.datetime-typed parameter, e.g. --start-date/--end-date) rejects every possible input string. No date format — plain date, full ISO-8601, anything — will parse.

Reproduction:

airflowctl dagrun list -e <env> --start-date "2026-07-01" --limit 1
# argument --start-date: invalid datetime value: '2026-07-01'

airflowctl dagrun list -e <env> --start-date "2026-07-01T00:00:00" --limit 1
# argument --start-date: invalid datetime value: '2026-07-01T00:00:00'

Root cause:

In airflow-ctl/src/airflowctl/ctl/cli_config.py, _python_type_from_string builds the argparse type= callable for CLI arguments straight from the OpenAPI-derived operation signatures:

mapping: dict[str, type | Callable] = {
    "int": int,
    "float": float,
    "bool": bool,
    "str": str,
    "bytes": bytes,
    "list": list,
    "dict": json_dict_type,
    "tuple": tuple,
    "set": set,
    "datetime.datetime": datetime.datetime,
    "dict[str, typing.Any]": json_dict_type,
}

For any parameter annotated datetime.datetime, this passes the bare datetime.datetime class to argparse as type=. argparse then calls type(value) on
the raw CLI string, i.e. datetime.datetime("2026-07-01") — invoetime.datetime(year, month, day, ...)), not a parser. Since theconstructor expects positional ints, passing a single string always raises a TypeError, which argparse reports as invalid datetime value: '...'` regardless
of the input.

Notably, the exact same class of bug existed for dict-typed parxed by mapping to json_dict_type (a real parser usingjson.loads) instead of the bare dict constructor. The datetime.datetime entry was missed and still uses the bare type.

What you think should happen instead?

datetime.datetime should map to an actual parsing function, not the bare class, e.g.:

def iso_datetime_type(val: str) -> datetime.datetime:
    """Parse an ISO-8601 datetime string."""
    try:
        return datetime.datetime.fromisoformat(val)
    except ValueError as e:
        raise argparse.ArgumentTypeError(f"invalid datetime value: {val!r}") from e

and:

"datetime.datetime": iso_datetime_type,

This mirrors the existing fix pattern already used for dict → `e mapping.

Operating System

macOS (also confirmed against a production Airflow instance, running Linux / Debian distroless)

Deployment

Other

Apache Airflow Provider(s)

No response

Versions of Apache Airflow Providers

Installed via uv tool install apache-airflow-ctl. This bug report is explicitly about the airflowctl tool.

Official Helm Chart version

Not Applicable

Kubernetes Version

Not Applicable

Helm Chart configuration

Not Applicable

Docker Image customizations

Not Applicable

Anything else?

Confirmed present at:

  • Tag airflow-ctl/0.1.5 (commit 30e72a3) — airflow-ctl/src/airflowctl/ctl/cli_config.py:517
  • main (as of 2026-07-22) — same file, cli_config.py:549, unchanged

Affects every argparse-generated CLI command whose underlying operation signature has a datetime.datetime-typed parameter (e.g. dagrun list --start-date/--end-date), not just this one command.

Are you willing to submit PR?
  • Yes I am willing to submit a PR!
Code of Conduct
Dominant language
Python
Stars
46.9k
Forks
17.9k
Avg merge
2d 5h
Merged PRs (30d)
480

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/airflow

All issues in apache/airflow

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.