-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Description
Apache Airflow version
Other Airflow 2/3 version (please specify below)
If "Other Airflow 2/3 version" selected, which one?
2.10.5
What happened?
Triggering a DAG in the Airflow UI doesn't work if the there is a Param with type object and a default value of {}. You can still trigger the same DAG with the Airflow API or from another DAG just fine.
It was working in Airflow 2.10.2. I haven't tried other Airflow versions yet.
What you think should happen instead?
You should be able to successfully trigger a DAG with a Param of type object and a default value of {} in the Airflow UI .
How to reproduce
from airflow.models import DAG, Param
from airflow.operators.python import PythonOperator
def print_params(**context):
print(context)
print(context["params"])
with DAG(
dag_id="object_params_example",
schedule_interval=None,
description="Testing object params",
params={
"object_with_empty_default": Param({}, type="object", description="a description of a param"),
},
) as dag:
PythonOperator(
task_id="print-params",
python_callable=print_params,
)Triggering this DAG in the UI doesn't work. And it should let us trigger a DAG here since an empty dictionary is indeed a valid JSON schema object.
And here is the output in the Chrome console:
Even if we type in an input into the text box, it doesn't work either.
Also, if we change the param in the DAG to this, it also doesn't work (of course, adding an input before triggering):
"object_with_default_none": Param(None, type="object", description="a description of a param"),If we change the param to this, it works fine:
"object_with_non_empty_default": Param({"key": "value"}, type="object", description="a description of a param"),This also works just fine:
"object_optional_no_default": Param(None, type=["null", "object"], description="a description of a param"),And all of these work fine if called from the API or another DAG using the TriggerDagRunOperator.
Operating System
Linux, Ubuntu 20.04 LTS and Ubuntu 24.04 LTS
Versions of Apache Airflow Providers
Doesn't matter
Deployment
Google Cloud Composer
Deployment details
Deployment doesn't matter. Also fails with locally installed Airflow version from pip.
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct