Skip to content

allow other states than success/failed in tasks by REST API #31420

Description

@JoranDox

Apache Airflow version

main (development)

What happened

see also: #25463

From the conversation there, it sounds like it's intended to be possible to set a task to "skipped" via REST API, but it's not.
Instead the next best thing we have is marking as success & adding a note.

What you think should happen instead

I see no reason for users to not just be able to set tasks to "skipped". I could imagine reasons to avoid "queued", and some other more "internal" states, but skipped makes perfect sense to me for

  • tasks that failed and got fixed externally
  • tasks that failed but are now irrelevant because of a newer run
    in case you still want to be able to see those in the future (actually, a custom state would be even better)

How to reproduce

# task is just a dictionary with the right values for below
r = requests.patch(
    f"{base_url}/api/v1/dags/{task['dag_id']}/dagRuns/{task['dag_run_id']}/taskInstances/{task['task_id']}",
    json={
        "new_state": "skipped",
    },
    headers={"Authorization": token},
)

-> r.json() gives
{'detail': "'skipped' is not one of ['success', 'failed'] - 'new_state'", 'status': 400, 'title': 'Bad Request', 'type': 'http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/stable-rest-api-ref.html#section/Errors/BadRequest'}

Operating System

/

Versions of Apache Airflow Providers

/

Deployment

Astronomer

Deployment details

/

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions