Skip to content

Unable to set DagRun state in create Dagrun endpoint ("Property is read-only - 'state'") #30075

Description

@SamWheating

Apache Airflow version

main (development)

What happened

While working on another change I noticed that the example POST from the API docs actually leads to a request Error:

 curl -X POST -H "Cookie: session=xxxx" localhost:8080/api/v1/dags/data_warehouse_dag_5by1a2rogu/dagRuns -d '{"dag_run_id":"string2","logical_date":"2019-08-24T14:15:24Z","execution_date":"2019-08-24T14:15:24Z","conf":{},"state":"queued","note":"strings"}'  -H 'Content-Type: application/json'

{
  "detail": "Property is read-only - '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"
}

I believe that this comes from the DagRunSchema marking this field as dump_only:

state = DagStateField(dump_only=True)

So either -

  1. The documentation / API spec is incorrect and this field cannot be set in the request
  2. The marshmallow schema is incorrect and this field is incorrectly marked as dump_only

I think that its the former, as there's even a test to ensure that this field can't be set in a request - I can look into this and fix it soon.

What you think should happen instead

The API should accept requested which follow examples from the documentation.

How to reproduce

Spin up breeze and POST a create dagrun request which attempts to set the DagRun state.

Operating System

Breeze

Versions of Apache Airflow Providers

No response

Deployment

Other

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

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