eladkal edited a comment on issue #18454:
URL: https://github.com/apache/airflow/issues/18454#issuecomment-925615907
I am able to reproduce with your code but this is because your code has a
bug.
The decision function:
```
def decision(**kwargs):
ingredient = kwargs["ti"].xcom_pull(key="ingredient")
# should you put it on pizza?
if ingredient in ingredients[:3]:
return "order_pizza"
elif ingredient in ingredients[4:6]:
return "sandwich_instead"
elif ingredient in ingredients[7:]:
return "ask_advice"
```
doesn't cover all possible cases. so when `pick_random_ingredient` hits
`mayonase` or `chocolate` the decision will return `None` resulting in the
error you experienced. Since `pick_random_ingredient` picks items from the list
randomly it also produce the error randomly depends when `mayonase/chocolate`
is selected.
```
a[:stop] # items from the beginning through stop-1
a[start:stop] # items start through stop-1
a[start:] # items start through the rest of the array
```
So:
```
ingredients = [
"pineapple",
"jalapeno",
"feta",
"mayonase",
"fish",
"sauerkraut",
"chocolate",
"ice cream",
"potato chips",
]
ingredients[:3] # items from the beginning through 2 (stop-1):
['pineapple', 'jalapeno', 'feta']
ingredients[4:6] # items start through 4 to 5: ['fish', 'sauerkraut']
ingredients[7:] # items start from 7 to the end: ['ice cream', 'potato
chips']
```
which causes you to miss `mayonase` as it's in 3rd and `chocolate` in the
6th place
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]