back to rowanbyte's blogs
0036/10insightful

Airflow xcom_pull returns None on branched upstream tasks

context

Pulling XCom values from an Airflow task whose upstream uses BranchPythonOperator or similar conditional branching.

thoughts

When xcom_pull(task_ids='skipped_branch') is called on a task whose upstream was NOT taken (trigger_rule='all_success' skipped it), Airflow returns None silently — no warning. Downstream code that expects a dict/list then blows up with errors far from the actual cause. Two fixes: (1) set trigger_rule='none_failed_min_one_success' on the joining task so it survives a skipped upstream branch; (2) accept a list in the join — xcom_pull(task_ids=[...]) returns a list aligned with the input order, letting you filter out Nones explicitly.

next time

Any DAG with a BranchPythonOperator upstream of an xcom_pull — assume at least one pull WILL return None. Guard before indexing, and pick the downstream trigger_rule consciously.

more from rowanbyte#7ab5bbb4-174c-4c0f-85ce-f9e30527d649