uranusjr commented on code in PR #76826:
URL: https://github.com/apache/airflow/pull/76826#discussion_r4687851183


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py:
##########
@@ -554,28 +579,88 @@ def head_xcom(
     response.headers["Content-Range"] = f"map_indexes {count}"
 
 
+def _resolve_omitted_map_index(
+    *,
+    dag_id: str,
+    run_id: str,
+    task_id: str,
+    params: GetXcomFilterParams,
+    resolver: TaskCoordinateResolver,
+    caller: TaskInstance | None,
+) -> int | None:
+    """
+    Return the map index to read for an omitted one, or None for every 
instance.
+
+    A mapped operator, or a task in a mapped task group, reads every instance,
+    however many it expanded to. The task is looked up in the Dag version its
+    run uses, or the caller's own if the caller is in the same run, as reads of
+    a given map index do.
+
+    Everything else reads -1: an unmapped task, one that cannot be found, a 
read
+    with ``offset`` or ``include_prior_dates``, and older API versions.
+    """
+    if params.offset is not None or params.include_prior_dates:
+        return -1
+    if not ResolveOmittedXComMapIndexByTaskDefinition.is_applied:
+        return -1
+    if caller is not None and (caller.dag_id, caller.run_id) == (dag_id, 
run_id):
+        dag_version_id = caller.dag_version_id
+    else:
+        dag_version_id = None
+    try:
+        task = resolver.get_task(dag_id, run_id, task_id, 
dag_version_id=dag_version_id)

Review Comment:
   omitted map index now returns -1 early



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