Skip to content

JSON config isn't showing default value when the params value is set to a dictionary #20736

@rustikk

Description

@rustikk

Apache Airflow version

2.2.3 (latest released)

What happened

When triggering a dag with the JSON config with the params value set to a dictionary with type="object" the default value is not displaying. The schema validation is still working, if you pass a value that isn't a dictionary an error will display in the UI.

What you expected to happen

I expected the default value to show in the JSON config.

How to reproduce

from datetime import datetime, timedelta

from airflow import DAG
from airflow.models.param import Param
from airflow.operators.python import PythonOperator

# unpausing causes this dag to run once, because there's only been
# one complete interval of 30 years since the epoch.
thirty_years = 1577862000  # seconds

with DAG(
    "params_dictionaries",
    start_date=datetime(1970, 1, 1),
    schedule_interval=timedelta(seconds=thirty_years),
    catchup=True,
    params={"x": Param({"a": {3, 4, 5}, "b": {1, 2, 3}}, type="object")},
    render_template_as_native_obj=True,
    ),
) as dag:

    def fail_if_invalid(val):
        print(val)
        # assert type(val) == dict

    PythonOperator(
        task_id="ref_param",
        python_callable=fail_if_invalid,
        op_args=["{{ params['x'] }}"]
    )

Operating System

Docker (debian:buster)

Versions of Apache Airflow Providers

2.2.3, 2.2.2, 2.2.1 gives an import error

Deployment

Astronomer

Deployment details

FROM quay.io/astronomer/ap-airflow-dev:2.2.3-onbuild
#FROM quay.io/astronomer/ap-airflow:2.2.2-buster-onbuild
#FROM quay.io/astronomer/ap-airflow-dev:2.2.1-buster-onbuild

Anything else

Problem occurs everytime.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    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