Apache Airflow version
2.6.3
What happened
When the condition in ShortCircuitOperator is truthy it is returned at
but when it is falsy, the function falls through without returning anything.
If multiple_outputs is set true (with for example @task.short_circuit(multiple_outputs=True) _handle_output of
DecoratedOperator at
|
if isinstance(return_value, dict): |
does not test for None and raises at
|
f"Returned output was type {type(return_value)} expected dictionary for multiple_outputs" |
This makes it impossible to pass a falsy value (i.e. an empty dictionary) so
ShortCircuitOperator is unusable with
multiple_outputs=true
What you think should happen instead
Probably the xcom_push should not be attempted with None, or possibly the condition should be returned by ShortCircuitOperator even if it is falsy
How to reproduce
@task.short_circuit(multiple_outputs=True)
def test():
return {}
Operating System
Ubuntu 22.04.2 LTS
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
2.6.3
What happened
When the condition in
ShortCircuitOperatoris truthy it is returned atairflow/airflow/operators/python.py
Line 252 in a2ae226
but when it is falsy, the function falls through without returning anything.
If
multiple_outputsis settrue(with for example@task.short_circuit(multiple_outputs=True)_handle_outputofDecoratedOperatoratairflow/airflow/decorators/base.py
Line 242 in a2ae226
does not test for None and raises at
airflow/airflow/decorators/base.py
Line 255 in a2ae226
This makes it impossible to pass a falsy value (i.e. an empty dictionary) so
ShortCircuitOperatoris unusable withmultiple_outputs=trueWhat you think should happen instead
Probably the
xcom_pushshould not be attempted withNone, or possibly the condition should be returned byShortCircuitOperatoreven if it is falsyHow to reproduce
Operating System
Ubuntu 22.04.2 LTS
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct