Skip to content

Jinja does not find XCom value with dynamic mapping for Airflow 3 #50686

@sveyret

Description

@sveyret

Apache Airflow version

3.0.1

If "Other Airflow 2 version" selected, which one?

No response

What happened?

We are using an operator in a dynamic mapping. One of the static values, defined in partial is a template, using Jinja to extract an XCom value. This XCom value is not found by Jinja and replaced with "None".

This was working with version 2.x

What you think should happen instead?

We expect the template to be replaced appropriately, as it was in Airflow 2.x.

How to reproduce

In the MVE below, the show task is displaying None instead of Show this:

from datetime import datetime from textwrap import dedent from airflow import DAG from airflow.decorators import task from airflow.providers.standard.operators.bash import BashOperator @task def build_something(): return "Show this" @task def build_multiple(): return [{"message": "Also this"}, {"message": "Also that"}] with DAG( "mve-xcom-jinja", default_args={ "depends_on_past": False, }, schedule=None, start_date=datetime(2025, 1, 1), catchup=False, ) as dag: something = build_something() multiple = something >> build_multiple() _ = multiple >> BashOperator.partial( task_id="show", bash_command=dedent( """  echo "{{ task_instance.xcom_pull(task_ids='build_something') }}"  echo "$message"  """ ), ).expand(env=multiple)

Operating System

Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

No response

Deployment

Other Docker-based deployment

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions