@classmethod def get_value(cls, key, dag_id, task_id, run_id, map_index): # Enforce exclusive pull: only if (dag_id, calling_task, target_task) is allowed calling_task = task_id # Note: in real implementation, you'd need to resolve caller allowed_keys = cls.ALLOWED_PULLS.get((dag_id, calling_task), []) if key not in allowed_keys: raise AirflowException( f"XCom exclusive violation: Task calling_task not allowed to pull key 'key'" ) return super().get_value(key, dag_id, task_id, run_id, map_index)
This default behavior introduces three major operational anti-patterns:
: Keep default XCom payloads under a few kilobytes.
Task B reads the link and automatically downloads the file from S3.
Unlike Variables, which are globally accessible to all DAGs, XComs are scoped exclusively to the DAG run in which they were created. The combination of dag_id , run_id , task_id , and map_index uniquely identifies each XCom. This means a downstream task can only pull an XCom from a known upstream task within the same DAG run—no accidental cross‑run contamination.