Jinja template in Airflow always change value to String

I have a custom defined Operator my_previous_job in Airflow that returns a Python list.

In my DAG definition, I reference it using jinja template:

t_my_job = MyOperator(
        "jobId": f"{{{{ ti.xcom_pull(task_ids='my_previous_job', "f"key='return_value')}}}}",

However, the value the f"{{{{ (ti.xcom_pull(task_ids='my_previous_job', "f"key='return_value')}}}})" returns is not a list, but a string with a list in it. i.e.

Instead of:


it returns a string:


What can I do to just get the list generated by the my_previous_job instead of a String?

1 answer

  • answered 2022-01-21 19:49 Elad Kalif

    For Airflow < 2.1.0: Rendering templated fields is always string.

    For Airflow >= 2.1.0: There is support for rendering fields as native Python Objects. You will need to set render_template_as_native_obj=True in the DAG object. You can read more about it in the docs.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum