Skip to content

ShortCircuitOperator returns None when condition is Falsy which errors with multiple_outputs=True #32553

@Dris101

Description

@Dris101

Apache Airflow version

2.6.3

What happened

When the condition in ShortCircuitOperator is truthy it is returned at

return condition

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?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions