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 schema array type does does not work with items element #39972

Closed
2 tasks done
techolga opened this issue May 31, 2024 · 3 comments · Fixed by #39993
Closed
2 tasks done

Param schema array type does does not work with items element #39972

techolga opened this issue May 31, 2024 · 3 comments · Fixed by #39993
Labels
area:core kind:bug This is a clearly a bug

Comments

@techolga
Copy link
Contributor

techolga commented May 31, 2024

Apache Airflow version

2.9.1

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

No response

What happened?

When I try to add item validation to an array type in the schema of a Param object passed to a DAG, the UI does render a Code box instead of an Array box and does not validate the jsonschema properly.

What you think should happen instead?

It should render the same UI element as it does when there is no field "items" in the schema.

How to reproduce

@dag(
    schedule=None,
    params={
        "mail": Param(
            schema={
                "title": "Email addresses",
                "type": ["array", "null"],
                # The following causes the issue (even "items": {} is enough)
                "items": {
                    "type": "string",
                    "format": "idn-email",
                    "minLength": 5,
                    "maxLength": 255,
                },
            }
        ),
    },
)
def any_dag():
	...

Test validation in REPL:

import jsonschema
schema={
    "type": ["array", "null"],
    "items": {
        "type": "string",
        "format": "idn-email",
        "minLength": 5,
        "maxLength": 255,
    },
}
jsonschema.validate(['test@mail.com'], schema, format_checker=jsonschema.FormatChecker())
# does not raise an exception

jsonschema.validate(['testmail.com'], schema, format_checker=jsonschema.FormatChecker())
# does raise an exception

Operating System

Debian GNU/Linux 12 (bookworm)

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==8.20.0
apache-airflow-providers-celery==3.6.2
apache-airflow-providers-cncf-kubernetes==8.1.1
apache-airflow-providers-common-io==1.3.1
apache-airflow-providers-common-sql==1.12.0
apache-airflow-providers-docker==3.10.0
apache-airflow-providers-elasticsearch==5.3.4
apache-airflow-providers-fab==1.0.4
apache-airflow-providers-ftp==3.8.0
apache-airflow-providers-google==10.17.0
apache-airflow-providers-grpc==3.4.1
apache-airflow-providers-hashicorp==3.6.4
apache-airflow-providers-http==4.10.1
apache-airflow-providers-imap==3.5.0
apache-airflow-providers-microsoft-azure==10.0.0
apache-airflow-providers-mysql==5.5.4
apache-airflow-providers-odbc==4.5.0
apache-airflow-providers-openlineage==1.7.0
apache-airflow-providers-postgres==5.10.2
apache-airflow-providers-redis==3.6.1
apache-airflow-providers-sendgrid==3.4.0
apache-airflow-providers-sftp==4.9.1
apache-airflow-providers-slack==8.6.2
apache-airflow-providers-smtp==1.6.1
apache-airflow-providers-snowflake==5.4.0
apache-airflow-providers-sqlite==3.7.1
apache-airflow-providers-ssh==3.10.1

Deployment

Docker-Compose

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

@techolga techolga added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels May 31, 2024
Copy link

boring-cyborg bot commented May 31, 2024

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

@RNHTTR RNHTTR removed the needs-triage label for new issues that we didn't triage yet label May 31, 2024
@RNHTTR
Copy link
Collaborator

RNHTTR commented May 31, 2024

Once this is resolved, there should probably be a doc page on using the schema parameter for a Param.

@techolga
Copy link
Contributor Author

techolga commented Jun 1, 2024

Totally agree, the docs do not describe the default behavior and the schema parameter for Param.

With #39993 at least the default behavior for string arrays is switched to present the standard array textarea which should be consistent with the docs and examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants