This happens because you use `task_ids=['tasks1']`
This is how xcom_pull works -you pass there list of tasks - and you get the
list of xcoms as a result. You need to add [0] : "{{
ti.xcom_pull(task_ids=['task1'],key='return_value')[0]}}". or you can also
pass task_id as you did. Both are fine.
XCom_Pull works in three "modes":
* when you pass array - it will return an array of xcoms - one for each
task in the erro-
* when you pass None, it will return array of xcoms from all tasks
* when you pass task_id - it will return the Xcom as a result (no array)
I hope it helps.
J.
On Mon, Aug 16, 2021 at 10:44 PM Kyle Nickl <[email protected]> wrote:
> So I run an operator that I name task1. It has an xcom return value. The
> value is display as a string as I would expect. But when I go to my next
> operator that does an xcom pull the value that gets passed in the in the
> value in an array that I see when the operator prints the value like
> ['my_value] instead of just my_value. I've tried on two different operators
> and same thing happens on both each time.
>
> But then whe I tried with a python operator using context inside the code
> like context['ti'].xcom_pull(task_ids='task1', key='return_value') the
> value is retrieved as expected and not in an array. Which surprised me.
>
> Any ideas on this or how I should properly retrieve this value when I'm
> trying to take the return_value and directly pass it in as a parameter
> value on another operator?
>
> Example (if the xcom return value is my_value the value the operator gets
> is ['my_value']:
> retrieveAndDisplayTokenOneWay = TestOperator(
> task_id='task2',
> something="{{ ti.xcom_pull(task_ids=['task1'],key='return_value')}}"
>
> Thanks!
>
>
--
+48 660 796 129