Skip to content

ScheduleInterval schema in OpenAPI specs should have "nullable: true" otherwise generated OpenAPI client will throw an error in case of nullable "schedule_interval" #22358

Closed

Description

@omarsmak

Apache Airflow version

2.2.4 (latest released)

What happened

Currently we have this schema definition in the OpenAPI specs:

    ScheduleInterval:
      description: |
        Schedule interval. Defines how often DAG runs, this object gets added to your latest task instance's
        execution_date to figure out the next schedule.
      readOnly: true
      oneOf:
        - $ref: '#/components/schemas/TimeDelta'
        - $ref: '#/components/schemas/RelativeDelta'
        - $ref: '#/components/schemas/CronExpression'
      discriminator:
        propertyName: __type

The issue with above is, when using an OpenAPI generator for Java for example (I think is same for other languages as well), it will treat ScheduleInterval as non-nullable property, although what is returned under /dags/{dag_id} or /dags/{dag_id}/details in case of a None schedule_interval is null for schedule_interval.

What you think should happen instead

We should have nullable: true in ScheduleInterval schema which will allow schedule_interval to be parsed as null.

How to reproduce

No response

Operating System

Linux

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else

If the maintainers think is a valid bug, I will be more than happy to submit a PR :)

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Mar 18, 2022

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. uranusjr commented on Mar 18, 2022

    @uranusjr
    Member

    Good catch. Pull request would be very welcomed!

  3. kianelbo commented on Apr 3, 2022

    @kianelbo
    Contributor

    Does adding allow_none=True argument to schedule_interval field suffice?
    If so, may I open the PR?

  4. omarsmak commented on Apr 3, 2022

    @omarsmak
    MemberAuthor

    I think it doesn't really help, the issue will be on the generated client side.
    Feel free to open a PR as I haven't get the time yet

  5. Bowrna commented on Jun 3, 2022

    @Bowrna
    Contributor

    Currently when I hit the below API
    http://127.0.0.1:28080/api/v1/dags/example_trigger_target_dag/details,

    I get the response:

    {
      "catchup": false,
      "concurrency": 16,
      "dag_id": "example_trigger_target_dag",
      "dag_run_timeout": null,
      "default_view": "grid",
      "description": null,
      "doc_md": null,
      "end_date": null,
      "file_token": ".eJxT0s8vKNFPzCxKy8kvh9OpFYm5BTmp8SmJ6cVwTklRZnp6alF8SWJRemoJSE6voFIJADOyGRw.vE-k8zZfRBEacXoSycU5gDkSXDk",
      "fileloc": "/opt/airflow/airflow/example_dags/example_trigger_target_dag.py",
      "is_active": true,
      "is_paused": false,
      "is_paused_upon_creation": null,
      "is_subdag": false,
      "last_parsed": "2022-06-03T11:07:15.950865+00:00",
      "max_active_runs": 16,
      "max_active_tasks": 16,
      "orientation": "LR",
      "owners": [
        "airflow"
      ],
      "params": {
    
      },
      "pickle_id": null,
      "render_template_as_native_obj": false,
      "schedule_interval": null,
      "start_date": "2021-01-01T00:00:00+00:00",
      "tags": [
        {
          "name": "example"
        }
      ],
      "timezone": "Timezone('UTC')"
    }
    

    How does setting the ScheduleInterval param to nullable:true will be useful?
    Edit: @uranusjr @omarsmak Could you help me in this?

  6. uranusjr commented on Jun 6, 2022

    @uranusjr
    Member

    From what I understand, the problem is not in the API response, but the generated API clients. The response you have above is currently not consumable by an API client. Adding nullable: true would allow the clients to handle "schedule_interval": null correctly. The generated API clients are not a part of the main Airflow repository, but they do rely on the openapi/v1.yml file in here, so we need to fix it for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions