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


##########
task-sdk/src/airflow/sdk/coordinators/_subprocess.py:
##########
@@ -901,8 +909,15 @@ def _get_xcom_backend() -> type[BaseXCom]:
     return xcom.XCom
 
 
-def _is_loaded_through_backend() -> bool:
-    return runs_in_helper(_get_xcom_backend())
+def _is_loaded_through_backend(key: str) -> bool:
+    """
+    Whether the value of ``key`` read from the XCom row must be resolved 
through the XCom backend.
+
+    Mirrors the set-side gate: a key that bypasses the backend when it is set 
(the skip decision and
+    operator extra links, which readers consume from the row as it is) holds 
its value as it is in the
+    row, so a get of it must not run the backend's load hook on that raw value.
+    """
+    return is_stored_through_backend(key) and not _is_extra_link(key) and 
runs_in_helper(_get_xcom_backend())

Review Comment:
   The get side reads rows any writer may have produced, so a key prefix cannot 
tell whether a row went through the backend. The Python SDK's 
`BaseXCom.get_one` always calls the load hook, and relies on the `load_value` 
contract (foreign rows go to `super()`). Can we keep that?



##########
task-sdk/src/airflow/sdk/coordinators/_subprocess.py:
##########
@@ -901,8 +909,15 @@ def _get_xcom_backend() -> type[BaseXCom]:
     return xcom.XCom
 
 
-def _is_loaded_through_backend() -> bool:
-    return runs_in_helper(_get_xcom_backend())
+def _is_loaded_through_backend(key: str) -> bool:
+    """
+    Whether the value of ``key`` read from the XCom row must be resolved 
through the XCom backend.
+
+    Mirrors the set-side gate: a key that bypasses the backend when it is set 
(the skip decision and
+    operator extra links, which readers consume from the row as it is) holds 
its value as it is in the
+    row, so a get of it must not run the backend's load hook on that raw value.
+    """
+    return is_stored_through_backend(key) and not _is_extra_link(key) and 
runs_in_helper(_get_xcom_backend())

Review Comment:
   Also, is this the right place for this? If reading of these keys should skip 
the backend, this logic should probably be in `airflow.sdk.bases.xcom`, or as a 
backend-overridable hook. Otherwise Python and other Task SDKs would resolve 
the same row differently.



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