Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Param does not work with type=['array', 'null'], items={'type': 'number'} and None default #45032

Open
1 of 2 tasks
daniel-westerfeld opened this issue Dec 18, 2024 · 0 comments
Labels
area:core area:UI Related to UI/UX. For Frontend Developers. kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet

Comments

@daniel-westerfeld
Copy link

daniel-westerfeld commented Dec 18, 2024

Apache Airflow version

Other Airflow 2 version (please specify below)

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

2.8.2

What happened?

I am trying to pass a parameter to a DAG using Param. I need to pass an optional list of integers, hence, I tried using type=['array', 'null'], items={'type': 'number'} with None as default value. However, when I try to trigger the DAG and add a non-None array of numbers, the JSON config does not get updated and null is passed.

What you think should happen instead?

The non-empty array of integers should get passed to the DAG.

How to reproduce

Create a DAG with the mentioned Param, e.g.

from airflow import DAG
from airflow.models.param import Param

default_args = {
    'owner': '[email protected]',
    'start_date': datetime(2023, 12, 13),
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

with DAG(
    'example_dag',
    default_args=default_args,
    schedule='0 1 * * *',
    tags=['news-dags'],
    params={
        'ids': Param(None, type=['array', 'null'], items={'type': 'number'}),
    },
) as example_dag:
    ...

Now try to trigger it with config and add a list of integer IDs. I noted, that it works when I specify type='array' but the default should be None. The behaviour of my DAG differs when ids are None or an empty list, so passing [] as a default and removing null is not an option.

Operating System

Debian bookworm

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==8.18.0
apache-airflow-providers-celery==3.6.0
apache-airflow-providers-common-io==1.3.0
apache-airflow-providers-common-sql==1.11.0
apache-airflow-providers-docker==3.9.1
apache-airflow-providers-ftp==3.7.0
apache-airflow-providers-http==4.9.1
apache-airflow-providers-imap==3.5.0
apache-airflow-providers-postgres==5.10.1
apache-airflow-providers-redis==3.6.0
apache-airflow-providers-sqlite==3.7.1

Deployment

Other Docker-based deployment

Deployment details

No response

Anything else?

Always when trying to use Param with the mentioned combination.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@daniel-westerfeld daniel-westerfeld added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels Dec 18, 2024
@dosubot dosubot bot added the area:UI Related to UI/UX. For Frontend Developers. label Dec 18, 2024
@daniel-westerfeld daniel-westerfeld changed the title Param does not work with type=['array', 'null'], items={'type': 'integer'} and None default Param does not work with type=['array', 'null'], items={'type': 'number'} and None default Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core area:UI Related to UI/UX. For Frontend Developers. kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet
Projects
None yet
Development

No branches or pull requests

1 participant