BasPH opened a new issue, #31869:
URL: https://github.com/apache/airflow/issues/31869

   ### Apache Airflow version
   
   2.6.1
   
   ### What happened
   
   I'm using `array` Params and sometimes want to provide no values.
   
   The Param is configured with `type=["array", "null"]` and a default value 
(e.g. `["a", "b", "c"]`). I would assume emptying the Param field would set an 
empty array or null in the generated configuration JSON, but instead Airflow 
sets the default value. I have to manually modify the generated configuration 
JSON to submit an empty array.
   
   Normal usage:
   
![image](https://github.com/apache/airflow/assets/6249654/61b24ab9-ad83-4b6d-9fcb-b47a55e88356)
   
   Clearing the param field sets the default value:
   
![image](https://github.com/apache/airflow/assets/6249654/ee6110e9-2829-4c47-8862-31503c7abdac)
   
   I have to manually modify the generated configuration JSON:
   
![image](https://github.com/apache/airflow/assets/6249654/bb4be772-0bb9-4be5-b2f8-280c8f5ad917)
   
   
   ### What you think should happen instead
   
   I expect Airflow to set an empty array or null value when a Param field is 
left empty (and `null` is set as Param type).
   
   ### How to reproduce
   
   ```python
   import datetime
   
   from airflow.decorators import dag, task
   from airflow.exceptions import AirflowSkipException
   from airflow.models import Param
   
   
   @dag(
       schedule=None,
       start_date=datetime.datetime(2023, 1, 1),
       params={
           "demo": Param(
               default=["a", "b", "c"],
               type=["array", "null"],
           )
       },
   )
   def dagrun_conf():
       @task
       def print_params(params=None):
           if params["demo"]:
               print(params["demo"])
           else:
               raise AirflowSkipException("Nothing to do here")
   
       print_params()
   
   
   dagrun_conf()
   
   ```
   
   ### Operating System
   
   N/A
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Astronomer
   
   ### 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
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to