uranusjr commented on code in PR #76826:
URL: https://github.com/apache/airflow/pull/76826#discussion_r4586202614
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py:
##########
@@ -553,6 +553,36 @@ def head_xcom(
response.headers["Content-Range"] = f"map_indexes {count}"
+def _resolve_requested_map_index(
+ *,
+ dag_id: str,
+ run_id: str,
+ task_id: str,
+ params: GetXcomFilterParams,
+ session: Session,
+ dag_bag: DBDagBag,
+) -> int | None:
+ """
+ Return the map index to read, or None for every instance of a mapped task.
+
+ An omitted map index is resolved by the producing task's definition in the
+ Dag version its run uses: a mapped operator, or a task in a mapped task
+ group, is mapped however many instances it expanded to. A task that cannot
+ be found reads -1, so the read reports the XCom as not found.
+ """
+ if params.map_index is not None:
+ return params.map_index
+ if params.offset is not None:
+ return -1 # None reads a mapped task's list.
+ try:
+ task = TaskCoordinateResolver(dag_bag, session).get_task(dag_id,
run_id, task_id)
+ except AmbiguousProducerError as error:
Review Comment:
Actually fixed. An omitted map index now resolves with the caller’s dag
version id when the caller is a task in the same run. Kind of accidentally
caused by the refactoring for not rebuilding resolver (I made a more
fundamental structural change with FastAPI dependency injection)
--
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]