Skip to content

Trigger UI form fails rendering if value with enum contains "null" value #62049

@jscheffl

Description

@jscheffl

Apache Airflow version

3.1.7

If "Other Airflow 3 version" selected, which one?

No response

What happened?

In Airflow 2.11 we use trigger forms with enum values in order to have users selecting a value with a choice. In Airflow 2.11 it was possible to also add a "null"/None value and make the field optional, also adding this to enum.

In Airflow 3 this fails rendering the form. This generates on the UI the error:

Image

What you think should happen instead?

The empty default should be rendered. And it should be possible to pick a "null" value.

Note that workarounds seem to be impossible: If the "null" value is removed from the list of values in enum and the user clicks on the "x" icon in the dropdown the value is cleared, form submission fails though with HTTP 400 as an empty field value is not in the enum list and therefore invalid.

How to reproduce

Start airflow e.g. via breeze start-airflow --load-example-dags and modify the airflow-core/src/airflow/example_dags/example_params_ui_tutorial.py and make the normal example dropdown being an optional field:

        "pick_with_label": Param(
            3,
            type=["number", "null"],
            title="Select one Number",
            description="With drop down selections you can also have nice display labels for the values.",
            enum=[*range(1, 10), None],
            values_display={
                1: "One",
                2: "Two",
                3: "Three",
                4: "Four - is like you take three and get one for free!",
                5: "Five",
                6: "Six",
                7: "Seven",
                8: "Eight",
                9: "Nine",
            },
            section="Drop-Downs and selection lists",
        ),

Click on the UI to trigger the form and the error above is displayed.

Operating System

any

Versions of Apache Airflow Providers

any

Deployment

Official Apache Airflow Helm Chart

Deployment details

any

Anything else?

Tested on main as well as 3.1.7 but might be existing for a longer time already.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:UIRelated to UI/UX. For Frontend Developers.good first issuekind:bugThis is a clearly a bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions