Airflow: REST API: DAGs schema does not allow "None" for schedule_interval

Created on 13 Oct 2020  路  3Comments  路  Source: apache/airflow

Apache Airflow version: v2.0.0.dev0 (latest master)

What happened:

Running Breeze on my local machine with sample DAGs.

Request made with Insomnia desktop client (same result using a web application client):

GET /api/v1/dags?limit=100 HTTP/1.1
Host: 127.0.0.1:28080
Authorization: Basic YWRtaW46YWRtaW4=
User-Agent: insomnia/2020.4.1
Cookie: session=.eJw1zjkKwzAQQNG7qE6hGS1j-TJmNpEUMUG2q5C7RxDSffjNe4etDz_uYT3H5bewPSysoSJEVWo9UW4sGNFN-iwVMozdXdViEa1VGjp2BUCuzA1JFmNyoCypYMXezBM4gs1ZkJVAeok1ZaSoZiQ1c5RlUbGUihdWljAhLx9P3n0__7Tr8PHjQfh8Ac-rNx4.X4WlQA.kuA0c8M57RIBSTP0iyebJAYkY8M
Accept: /

500 error response:

{
  "detail": "None is not valid under any of the given schemas\n\nFailed validating 'oneOf' in schema['allOf'][0]['properties']['dags']['items']['properties']['schedule_interval']:\n    {'description': 'Schedule interval. Defines how often DAG runs, this '\n                    \"object gets added to your latest task instance's\\n\"\n                    'execution_date to figure out the next schedule.\\n',\n     'discriminator': {'propertyName': '__type'},\n     'oneOf': [{'description': 'Time delta',\n                'properties': {'__type': {'type': 'string'},\n                               'days': {'type': 'integer'},\n                               'microseconds': {'type': 'integer'},\n                               'seconds': {'type': 'integer'}},\n                'required': ['__type', 'days', 'seconds', 'microseconds'],\n                'type': 'object',\n                'x-scope': ['',\n                            '#/components/schemas/DAGCollection',\n                            '#/components/schemas/DAG',\n                            '#/components/schemas/ScheduleInterval']},\n               {'description': 'Relative delta',\n                'properties': {'__type': {'type': 'string'},\n                               'day': {'type': 'integer'},\n                               'days': {'type': 'integer'},\n                               'hour': {'type': 'integer'},\n                               'hours': {'type': 'integer'},\n                               'leapdays': {'type': 'integer'},\n                               'microsecond': {'type': 'integer'},\n                               'microseconds': {'type': 'integer'},\n                               'minute': {'type': 'integer'},\n                               'minutes': {'type': 'integer'},\n                               'month': {'type': 'integer'},\n                               'months': {'type': 'integer'},\n                               'second': {'type': 'integer'},\n                               'seconds': {'type': 'integer'},\n                               'year': {'type': 'integer'},\n                               'years': {'type': 'integer'}},\n                'required': ['__type',\n                             'years',\n                             'months',\n                             'days',\n                             'leapdays',\n                             'hours',\n                             'minutes',\n                             'seconds',\n                             'microseconds',\n                             'year',\n                             'month',\n                             'day',\n                             'hour',\n                             'minute',\n                             'second',\n                             'microsecond'],\n                'type': 'object',\n                'x-scope': ['',\n                            '#/components/schemas/DAGCollection',\n                            '#/components/schemas/DAG',\n                            '#/components/schemas/ScheduleInterval']},\n               {'description': 'Cron expression',\n                'properties': {'__type': {'type': 'string'},\n                               'value': {'type': 'string'}},\n                'required': ['__type', 'value'],\n                'type': 'object',\n                'x-scope': ['',\n                            '#/components/schemas/DAGCollection',\n                            '#/components/schemas/DAG',\n                            '#/components/schemas/ScheduleInterval']}],\n     'readOnly': True,\n     'x-scope': ['',\n                 '#/components/schemas/DAGCollection',\n                 '#/components/schemas/DAG']}\n\nOn instance['dags'][3]['schedule_interval']:\n    None",
  "status": 500,
  "title": "Response body does not conform to specification",
  "type": "https://airflow.readthedocs.io/en/latest/stable-rest-api-ref.html#section/Errors/Unknown"
}

What you expected to happen:

I expected to not receive error response and instead receive an array of DAG objects.

E.G.

{
  "dags": [
    {
      "dag_id": "example_bash_operator",
      "description": null,
      "fileloc": "/opt/airflow/airflow/example_dags/example_bash_operator.py",
      "is_paused": false,
      "is_subdag": false,
      "owners": [
        "airflow"
      ],
      "root_dag_id": null,
      "schedule_interval": {
        "__type": "CronExpression",
        "value": "0 0 * * *"
      },
      "tags": [
        {
          "name": "example"
        }
      ]
    },
    {
      "dag_id": "example_branch_dop_operator_v3",
      "description": null,
      "fileloc": "/opt/airflow/airflow/example_dags/example_branch_python_dop_operator_3.py",
      "is_paused": true,
      "is_subdag": false,
      "owners": [
        "airflow"
      ],
      "root_dag_id": null,
      "schedule_interval": {
        "__type": "CronExpression",
        "value": "*/1 * * * *"
      },
      "tags": [
        {
          "name": "example"
        }
      ]
    }
  ],
  "total_entries": 26
}

Anything else we need to know:

Deleting the sample DAGs with a schedule of "None" or reducing the query limit to a smaller value (that omits any DAGs w/ "None" schedule) prevents the error response from occurring.

API bug

All 3 comments

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

@ephraimbuddy is this something you could look at?

Yes. I will take a look. Assign it to me

Was this page helpful?
0 / 5 - 0 ratings