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` the decision will return `None` resulting in the error you 
experienced.
   
   ```
   a[start:stop]  # items start through stop-1
   a[:stop]       # items from the beginning through stop-1
   ```
   So:
   ```
   ingredients[:3] #  items from the beginning through 2
   ingredients[4:6]  # items start through 4 to 6
   ```
   which causes you to miss `mayonase` as it's in place 3.


-- 
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]


Reply via email to