IamJasonBian opened a new pull request, #66509:
URL: https://github.com/apache/airflow/pull/66509

   **Stacked on top of #66202** — opening as a draft so the follow-up is 
visible while #66202 is still in review.
   
   Addresses @parkhojeong's [CHANGES_REQUESTED feedback on 
#66202](https://github.com/apache/airflow/pull/66202#discussion_r2552015400): 
the new `airflowctl tasks state` command currently can't query a mapped task 
instance, so it doesn't match legacy `airflow tasks state --map-index`. The 
Airflow REST API exposes a separate path-parameter endpoint for mapped 
instances:
   
   - unmapped: `GET 
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}`
   - mapped:   `GET 
/api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}`
   
   Hitting the unmapped endpoint for a mapped TI returns a 404 with the message 
*"Task instance is mapped, add the map_index value to the URL"*, so today the 
command just hard-fails on any mapped task.
   
   ## Changes (top commit only — `7156ab6`)
   
   - `TaskInstancesOperations.get` now accepts an optional `map_index` and 
routes to the mapped endpoint when it's non-negative. Sentinel uses the 
existing `int = None  # type: ignore` pattern from `XComOperations` so the 
auto-generated `taskinstances get` command continues to work when the flag is 
omitted.
   - New `--map-index` flag on `airflowctl tasks state` (default `-1`, matching 
legacy `airflow tasks state` semantics).
   - Three new parametrized unit tests for the mapped path (`map_index ∈ {0, 1, 
7}`); existing unmapped tests untouched.
   - The auto-generated `taskinstances get` command also gains optional 
`--map-index` support transparently.
   
   ## Stacking note
   
   The bottom two commits in this branch (`cfdb6617`, `f1e90629`) belong to 
@hyungryuk from #66202 — they're only here because #66202 hasn't merged yet. 
Once #66202 lands, this PR will rebase to the single `7156ab6` commit (52 +/3 - 
across 4 files) and come out of draft.
   
   If @hyungryuk would prefer to fold the map-index support directly into 
#66202 instead of landing it as a follow-up, I'm happy to close this and push 
the diff there as a suggested change.
   
   related: #66174
   follows: #66202
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.7)
   
   Generated-by: Claude Code (Opus 4.7) 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]

Reply via email to