You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Result of expanded task is None instead of empty list when all mapped tasks return None #48005
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()
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
I think it should be an empty list to maintain consistent behavior. This is important if you want to use this filtered list to expand downstream tasks upon.
Also: if you'd change return [1, 3] to return [1, 2, 3] in the provided DAG, the result will be [2] (i.e. a single 2 wrapped inside a list) and not just 2. So, always return a list, I'd say :)
Quick note, reproduced this issue on 2.10.5, also seems as though it has been resolved in the main branch. Running the DAG on main will return an empty list "[]" rather then None.
Quick note, reproduced this issue on 2.10.5, also seems as though it has been resolved in the main branch. Running the DAG on main will return an empty list "[]" rather then None.
This was indeed fixed on main and now has regressed. Would be nice to know what the desired outcome is from maintainers perspective and then add tests for this 😄
Closing as resolved - the literal example in this issue works properly as the .expand(...) now covers it.
However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause.
Created a PR to solve it #69075.
Closing as resolved - the literal example in this issue works properly as the .expand(...) now covers it. However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause. Created a PR to solve it #69075.
@shahar1 Are you sure that this issue here is resolved? I can reproduce it with an 3.2.2 installation, copy pasting the example dag above. display_results prints None instead of an empty list for me.
Thanks for looking into it and the PR 🫶
Closing as resolved - the literal example in this issue works properly as the .expand(...) now covers it. However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause. Created a PR to solve it #69075.
@shahar1 Are you sure that this issue here is resolved? I can reproduce it with an 3.2.2 installation, copy pasting the example dag above. display_results prints None instead of an empty list for me.
Thanks for looking into it and the PR 🫶
Closing as resolved - the literal example in this issue works properly as the .expand(...) now covers it. However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause. Created a PR to solve it #69075.
@shahar1 Are you sure that this issue here is resolved? I can reproduce it with an 3.2.2 installation, copy pasting the example dag above. display_results prints None instead of an empty list for me.
Thanks for looking into it and the PR 🫶
Please let me double check on it, reopening.
@Desdroid
When running on main, I got the following output:
[2026-06-30T07:40:47.208203Z] INFO - LazyXComSequence(<unevaluated length>)
[2026-06-30T07:40:47.208477Z] INFO - Done. Returned value was: None
display_results returns None because it just logs (logger.info(results)) and doesn't actually return anything.
@shahar1 But the desired behavior (at least in my eyes) is that it returns [] and not None.
Hey, I was too focused on solving the other bug so I completely missed out the real intent of this issue - my sincere apologies for that.
As it changes an existing core behavior, it will require a discussion and lazy consensus on Airflow's dev list. If you already did so in the past, could you please bump it? Otherwise, could you please create a thread for that? (With expalanation of the necessity, examples for misusage of current behavior, etc.)
Closing as resolved - the literal example in this issue works properly as the .expand(...) now covers it. However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause. Created a PR to solve it #69075.
@shahar1 Are you sure that this issue here is resolved? I can reproduce it with an 3.2.2 installation, copy pasting the example dag above. display_results prints None instead of an empty list for me.
Thanks for looking into it and the PR 🫶
Please let me double check on it, reopening.
@Desdroid When running on main, I got the following output:
[2026-06-30T07:40:47.208203Z] INFO - LazyXComSequence(<unevaluated length>)
[2026-06-30T07:40:47.208477Z] INFO - Done. Returned value was: None
display_results returns None because it just logs (logger.info(results)) and doesn't actually return anything.
Reclosing :)
Well, I should've double checked before posting. Somehow got confused which log line was which. Indeed LazyXComSequence is received which is the desired behavior from my point of view. I'm sincerely sorry for the confusion.
@shahar1 But the desired behavior (at least in my eyes) is that it returns [] and not None.
I am against this. Why should a method that does not have a return statement suddenly return an empty list? This is different from how (normal) python works and I'd consider it unpythonic.
The original title of this issue is Result of expanded task is None instead of empty list when all mapped tasks return None and also from the previous comments and description i understood that it was about the display_results() receiving None as a result of the expanded tasks while it now receives LazyXComSequence -> empty list, which is correct imo.
Closing as resolved - the literal example in this issue works properly as the .expand(...) now covers it. However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause. Created a PR to solve it #69075.
@shahar1 Are you sure that this issue here is resolved? I can reproduce it with an 3.2.2 installation, copy pasting the example dag above. display_results prints None instead of an empty list for me.
Thanks for looking into it and the PR 🫶
Please let me double check on it, reopening.
@Desdroid When running on main, I got the following output:
[2026-06-30T07:40:47.208203Z] INFO - LazyXComSequence(<unevaluated length>)
[2026-06-30T07:40:47.208477Z] INFO - Done. Returned value was: None
display_results returns None because it just logs (logger.info(results)) and doesn't actually return anything.
Reclosing :)
Well, I should've double checked before posting. Somehow got confused which log line was which. Indeed LazyXComSequence is received which is the desired behavior from my point of view. I'm sincerely sorry for the confusion.
@shahar1 But the desired behavior (at least in my eyes) is that it returns [] and not None.
I am against this. Why should a method that does not have a return statement suddenly return an empty list? This is different from how (normal) python works and I'd consider it unpythonic.
The original title of this issue is Result of expanded task is None instead of empty list when all mapped tasks return None and also from the previous comments and description i understood that it was about the display_results() receiving None as a result of the expanded tasks while it now receives LazyXComSequence -> empty list, which is correct imo.
Therefore I'd vote to close this.
It's alright, no worries :) At least we're all aware of what it is all about now.
Anyway, considering that you're against it, I don't fully understand that intent, and Cedric, as the issue author, doesn't plan to push it - I don't see this going anywhere.
However, as I've already swayed between closing and reopening this issue too much for one day, I'll leave it as pending-response until someone else justifies it, or creates the thread on the dev list, or that the issue gets auto-closed - whichever comes first.
This issue has been automatically marked as stale because it has been open for 14 days with no response from the author. It will be closed in next 7 days if no further activity occurs from the issue author.
Activity
boring-cyborg commentedon Mar 20, 2025
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
sunank200 commentedon Mar 24, 2025
With the DAG you provided, I am able to replicate this issue, and it is returning
None. Do we want to change this behaviour?cc: @pankajastro WDYT?
cedricdeboom commentedon Mar 24, 2025
I think it should be an empty list to maintain consistent behavior. This is important if you want to use this filtered list to expand downstream tasks upon.
Also: if you'd change
return [1, 3]toreturn [1, 2, 3]in the provided DAG, the result will be[2](i.e. a single 2 wrapped inside a list) and not just2. So, always return a list, I'd say :)isaiahiruoha commentedon Aug 8, 2025
Quick note, reproduced this issue on 2.10.5, also seems as though it has been resolved in the main branch. Running the DAG on main will return an empty list "[]" rather then None.
Desdroid commentedon Jun 26, 2026
This was indeed fixed on main and now has regressed. Would be nice to know what the desired outcome is from maintainers perspective and then add tests for this 😄
shahar1 commentedon Jun 27, 2026
Closing as resolved - the literal example in this issue works properly as the
.expand(...)now covers it.However, #69036 is indeed a new issue caused by migration to the task sdk, which has a similar root cause.
Created a PR to solve it #69075.
Desdroid commentedon Jun 29, 2026
@shahar1 Are you sure that this issue here is resolved? I can reproduce it with an 3.2.2 installation, copy pasting the example dag above.
display_resultsprintsNoneinstead of an empty list for me.Thanks for looking into it and the PR 🫶
shahar1 commentedon Jun 29, 2026
Please let me double check on it, reopening.
shahar1 commentedon Jun 30, 2026
@Desdroid
When running on main, I got the following output:
display_resultsreturnsNonebecause it just logs (logger.info(results)) and doesn't actually return anything.Reclosing :)
cedricdeboom commentedon Jun 30, 2026
@shahar1 But the desired behavior (at least in my eyes) is that it returns
[]and notNone.shahar1 commentedon Jun 30, 2026
Hey, I was too focused on solving the other bug so I completely missed out the real intent of this issue - my sincere apologies for that.
As it changes an existing core behavior, it will require a discussion and lazy consensus on Airflow's dev list. If you already did so in the past, could you please bump it? Otherwise, could you please create a thread for that? (With expalanation of the necessity, examples for misusage of current behavior, etc.)
Thank you! Reopening again.
cedricdeboom commentedon Jun 30, 2026
I'm not an active contributor here, but I feel that @Desdroid is well-placed to defend the change :) so I'll leave it up to them!
Desdroid commentedon Jul 1, 2026
Well, I should've double checked before posting. Somehow got confused which log line was which. Indeed LazyXComSequence is received which is the desired behavior from my point of view. I'm sincerely sorry for the confusion.
I am against this. Why should a method that does not have a return statement suddenly return an empty list? This is different from how (normal) python works and I'd consider it unpythonic.
The original title of this issue is
Result of expanded task is None instead of empty list when all mapped tasks return Noneand also from the previous comments and description i understood that it was about thedisplay_results()receivingNoneas a result of the expanded tasks while it now receivesLazyXComSequence-> empty list, which is correct imo.Therefore I'd vote to close this.
shahar1 commentedon Jul 1, 2026
It's alright, no worries :) At least we're all aware of what it is all about now.
Anyway, considering that you're against it, I don't fully understand that intent, and Cedric, as the issue author, doesn't plan to push it - I don't see this going anywhere.
However, as I've already swayed between closing and reopening this issue too much for one day, I'll leave it as
pending-responseuntil someone else justifies it, or creates the thread on the dev list, or that the issue gets auto-closed - whichever comes first.github-actions commentedon Jul 18, 2026
This issue has been automatically marked as stale because it has been open for 14 days with no response from the author. It will be closed in next 7 days if no further activity occurs from the issue author.
github-actions commentedon Jul 25, 2026
This issue has been closed because it has not received response from the issue author.