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

   **Description**
   
   Fix upstream map index resolution for dynamically mapped task groups when 
placeholder task instances are replaced during expansion.
   
   After expansion, the upstream placeholder (`map_index = -1`) is replaced by 
the first expanded task instance (`map_index = 0`). Downstream task instances 
that are still unexpanded may continue to reference the placeholder, causing 
incorrect upstream dependency resolution.
   
   This change introduces a small helper (`resolve_placeholder_map_index`) that 
is invoked during upstream map index resolution to correctly handle this 
transition, while preserving existing behavior for already-expanded downstream 
tasks.
   
   **Rationale**
   
   Placeholder task instances are a temporary pre-expansion representation. 
Once expansion occurs, they are no longer valid references, but downstream 
resolution logic may still encounter them. Handling this transition explicitly 
prevents downstream tasks from treating completed upstream work as unresolved.
   
   This could cause implicit dependencies to be skipped during DAG evaluation 
under certain trigger rules (such as `NONE_FAILED_MIN_ONE_SUCCESS`), 
particularly when multiple parallel task streams within the `MappedTaskGroup 
`converge on a single downstream task outside the group. As a result, DAG runs 
could be incorrectly marked as failed or skipped despite valid upstream 
execution.
   
   Please refer to issue https://github.com/apache/airflow/issues/59289 for 
more context. This PR was opened in response to that. The author of the issue 
reported the bug in Airflow 3.0.6 but I can confirm that the same issue is 
present in Airflow 3.1.5 (as well as the main branch at the time of opening 
this PR).
   
   **Tests**
   
   Added a test covering the post-expansion state where:
   
   - The upstream placeholder has been expanded.
   - The downstream task instance is either unexpanded or expanded.
   
   The test asserts that `get_relevant_upstream_map_indexes` returns the 
correct upstream map index in both cases.
   
   Closes: https://github.com/apache/airflow/issues/59289
   


-- 
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