ccoliu opened a new issue, #77579:
URL: https://github.com/apache/airflow/issues/77579
### Airflow CTL Version
Latest stable version
### Airflow CTL Command
airflowctl tasks state loop_ctl body.step ctl1
### Keyring Backend / Version
Keyring Backend/Headless
### Auth Type
Token
### What is the current behaviour?
Every iteration of a task loop has a task instance with the same Dag id, run
id, task id and map index. The API tells them apart by `region_id` and
`region_index` and rejects a lookup without them. `tasks state`, `tasks
failed-deps` and `tasks logs` only take `--map-index`, so they can't reach any
task instance inside a loop:
```
$ airflowctl tasks state loop_ctl body.step ctl1
Server response error: Client error message: {'detail': 'Select a region and
index for this task instance'}
Client error, Please check the command and its parameters. If you need
help, run the command with --help.
```
None of the command's parameters can select the iteration, though. `tasks
states-for-dag-run` lists the iterations without their region, so they look
like duplicate rows:
```
$ airflowctl tasks states-for-dag-run loop_ctl ctl1 -o table
dag_id | task_id | state | ...
loop_ctl | body.step | success | ...
loop_ctl | body.stop_at_three | success | ...
loop_ctl | body.step | success | ...
loop_ctl | body.stop_at_three | success | ...
loop_ctl | body.step | success | ...
loop_ctl | body.stop_at_three | success | ...
```
### What is the expected results?
- `tasks state`, `tasks failed-deps` and `tasks logs` accept `--region-id`
and `--region-index` and pass them to the API, as the UI does.
- When the API answers "Select a region and index for this task instance",
the command says the task runs inside a task loop and which options to pass.
- `tasks states-for-dag-run` shows `region_id` and `region_index` for task
instances in a loop.
### Anything else?
Found on main against an `apache/airflow:3.4.0` server. `tasks state`,
`failed-deps` and `logs` aren't in a release yet (0.1.6 only has
`states-for-dag-run`), so this can be fixed before they ship.
Reproduction Dag (trigger it and let it run its 3 iterations):
```python
import pendulum
from airflow.sdk import DAG, task, task_group
with DAG("loop_ctl", start_date=pendulum.datetime(2026, 1, 1, tz="UTC"),
schedule=None):
@task_group
def body():
@task
def step(*, loop):
return loop.index
step()
def stop_at_three(*, loop):
return loop.result >= 3
body.loop(max_iterations=5, until=stop_at_three)
```
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]