DAG Param incorrectly convert enum objects to strings
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.8k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 483
Description
### Apache Airflow version
2.10.1
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
Using a DAG Param with a type of `object` and `enum` set to a list of possible objects is reflected as a string in Trigger DAG UI, both in the selector and in the underlying JSON.

When attempting to run the DAG using the value, the DAG will fail to run

### What you think should happen instead?
JSON schemas support enums of any type
> Elements in the array might be of any type, including null.
(source: https://json-schema.org/draft/2020-12/json-schema-validation#section-6.1.2-3) . They should be configurable and supported by DAG Parameters, and should allow for successful selection and execution of the DAG from the Trigger DAG UI.
### How to reproduce
Create the following DAG
```python
from airflow.decorators import dag, task
from pendulum import datetime
from airflow.models.param import Param
keys = ["a", "b", "c"]
values_display_list = [{"key": key, "value": key.upper()} for key in keys]
@dag(
start_date=datetime(2024, 1, 1),
schedule=None,
catchup=False,
params={
"x": Param(
values_display_list[0],
type=["object"],
enum=values_display_list,
),
},
tags=["example"],
)
def example_params():
@task
def example_params_task(*, params, **kwargs) -> None:
if params:
print(f"Params: {params}")
else:
print("No Params")
example_params_task()
# Instantiate the DAG
example_params()
```
### Operating System
Debian 12 (Bookworm)
### Versions of Apache Airflow Providers
apache-airflow==2.10.1+astro.1
### Deployment
Other Docker-based deployment
### Deployment details
Astro CLI running Astro Runtime 12.1.0
### Anything else?
I think this issue might be caused by the the trigger templating at https://github.com/apache/airflow/blob/2.10.2/airflow/www/templates/airflow/trigger.html#L77-L86
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
Contributor guide
Research direction
Start with airflow/www/templates/airflow/trigger.html at the trigger form code referenced in the report, then reproduce the example DAG with an object-valued Param and enum. Trace how the selected enum value is represented in the Trigger DAG UI and submitted; done means object values remain objects and the DAG runs successfully with the selected value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- full-stack
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100