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

   ## Summary
   
   Fixes #67265: `@task.branch` / `BranchPythonOperator` inside `expand()` / 
`expand_kwargs()` mapped TaskGroups did not skip non-selected siblings — those 
tasks **ran** (wrong side effects / wasted compute).
   
   ### Root cause
   
   `NotPreviouslySkippedDep` used:
   
   ```python
   xcom_map_index = ti.map_index if parent.is_mapped else -1
   ```
   
   Operators inside a mapped TaskGroup are **not** `MappedOperator`s, but their 
TIs still write SkipMixin XCom at the runtime `map_index`. Looking up with `-1` 
misses that XCom, so the skip decision is invisible.
   
   This is the inverse of #62118 (unmapped parent → mapped child must still use 
`-1`).
   
   ### Fix
   
   ```python
   if parent.is_mapped or parent.get_closest_mapped_task_group() is not None:
       xcom_map_index = ti.map_index
   else:
       xcom_map_index = -1
   ```
   
   ### Tests
   
   - `expand` and `expand_kwargs`: non-selected sibling at the same `map_index` 
is skipped; selected sibling is not
   - Cross-`map_index` isolation (XCom for index 0 must not skip index 1)
   - Existing unmapped-parent → mapped-child coverage (#62118) retained
   
   Note: #67439 attempted this but was stale-closed before merge.
   
   ## Test plan
   
   - [ ] `pytest 
airflow-core/tests/unit/ti_deps/deps/test_not_previously_skipped_dep.py`
   - [ ] CI
   
   
   Made with [Cursor](https://cursor.com)


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