Skip to content

Airflow REST API Get tasks for DAG returns error if DAG task has trigger rule one_done #35186

Description

@deanobob

Apache Airflow version

Other Airflow 2 version (please specify below)

What happened

Experienced in version 2.6.1 but appears to be an issue in the latest version too.

When using the Airflow REST API /api/v1/dags/{dag name}/tasks to query the tasks of a DAG that contains a task with the trigger rule 'one_done' an error is returned:

{
  "detail": "'one_done' is not one of ['all_success', 'all_failed', 'all_done', 'one_success', 'one_failed', 'none_failed', 'none_skipped', 'none_failed_or_skipped', 'none_failed_min_one_success', 'dummy']\n\nFailed validating 'enum' in schema['properties']['tasks']['items']['properties']['trigger_rule']:\n    {'description': 'Trigger rule.\\n'\n                    '\\n'\n                    '*Changed in version 2.2.0*: '\n                    \"'none_failed_min_one_success' is added as a possible \"\n                    'value.\\n',\n     'enum': ['all_success',\n              'all_failed',\n              'all_done',\n              'one_success',\n              'one_failed',\n              'none_failed',\n              'none_skipped',\n              'none_failed_or_skipped',\n              'none_failed_min_one_success',\n              'dummy'],\n     'type': 'string'}\n\nOn instance['tasks'][6]['trigger_rule']:\n    'one_done'",
  "status": 500,
  "title": "Response body does not conform to specification",
  "type": "https://airflow.apache.org/docs/apache-airflow/2.6.1/stable-rest-api-ref.html#section/Errors/Unknown"
}

This appears to be an issue with the openapi spec, specifically the trigger_rules enum which is missing some valid trigger rules:

class TriggerRule(str, Enum):

I believe the openapi spec needs to include one_done. It should also be updated to include all_done_setup_success, always, and all_skipped.

What you think should happen instead

DAG tasks should be returned with the trigger rule one_done

How to reproduce

Create a DAG, add a task with a trigger rule of one_done. Call the Get tasks API: https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_tasks

Operating System

Ubuntu 22.04

Versions of Apache Airflow Providers

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:APIAirflow's REST/HTTP APIkind:bugThis is a clearly a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions