itzzdev09 opened a new pull request, #72163:
URL: https://github.com/apache/airflow/pull/72163
Adds `airflowctl tasks state`, the missing counterpart to the deprecated
`airflow tasks state`, which is already annotated
`@deprecated_for_airflowctl("airflowctl tasks state")` in
`airflow-core/src/airflow/cli/commands/task_command.py` but had nothing to
point at.
The command selects a Dag run with either `run_id` or `--logical-date` and
prints the state of the task instance. It goes through the existing
`task_instances.get` endpoint, so no change to `operations.py` was needed.
To stay consistent with the sibling commands, it reuses the argument
handling, validation and error wording already used by `tasks failed-deps`:
- exactly one of `run_id` / `--logical-date` is required
- `--logical-date` must be parseable and timezone-aware
- `--map-index` is reported in the 404 message, so a missing mapped instance
is distinguishable from a missing task
- non-404 API errors propagate rather than being swallowed
It prints `None` for a task instance with no state, matching the output of
the deprecated command so scripts migrating across keep working.
```
$ airflowctl tasks state example_dag run_this
manual__2025-01-01T00:00:00+00:00
success
```
closes: #66174
### Tests
16 new tests in `TestState` covering state values, unset state, map index,
logical-date lookup, both argument-validation failures, bad logical dates, 404
handling with and without a map index, missing Dag run, and non-404 propagation.
`46 passed` for the full `test_task_command.py` file — no existing test was
modified. `ruff check`, `ruff format --check` and `mypy` are clean on the
changed files.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Sonnet 5)
Generated-by: Claude Code (Sonnet 5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]