cedricdeboom opened a new issue, #48005:
URL: https://github.com/apache/airflow/issues/48005

   ### Apache Airflow version
   
   2.10.5
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   Upon expanding a task using a list of variables, the return value of the 
task should be a list of all the individual return values. When the return 
value of one mapped task is None, it is automatically filtered out of this 
list. You might expect then that if _all_ mapped tasks return None, the list is 
empty. However, that is not the case. Instead of returning an empty list, the 
return value is None. This causes issues if the output is used to expand upon 
in downstream tasks.
   
   ### What you think should happen instead?
   
   The return value of an expanded task should _always_ be a list, even if all 
the mapped tasks have returned None (in which case the list should be empty, 
not None).
   
   ### How to reproduce
   
   Example dag to reproduce.
   
   ```
   import logging
   from datetime import datetime
   from airflow.decorators import dag, task
   
   logger = logging.getLogger(__name__)
   
   @dag(schedule=None, start_date=datetime(2024, 3, 20), catchup=False, 
dag_id="example_dag")
   def example_dag():
   
       @task
       def generate_data():
           # Generating a list of numbers
           return [1, 3]
   
       @task
       def filter_data(number):
           # Filtering only even numbers
           return number if number % 2 == 0 else None
   
       @task
       def display_results(results):
           logger.info(results)
   
       numbers = generate_data()
   
       filtered_numbers = filter_data.expand(number=numbers)
       display_results(filtered_numbers)
   
   example_dag()
   ```
   
   ### Operating System
   
   MacOS Sequoia 15.3.2
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   Standalone
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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