Trigger dag_run response: Property is read-only - 'dag_id' - 400
zs1621 opened this issue · 8 comments
func workoutDagTask(workout_id int64, workout_path string) {
cli := airflow.NewAPIClient(&airflow.Configuration{
Scheme: "http",
Host: "localhost:8080",
BasePath: "/api/v1",
})
cred := airflow.BasicAuth{
UserName: "admin",
Password: "admin",
}
ctx := context.WithValue(context.Background(), airflow.ContextBasicAuth, cred)
var dagRunRequest airflow.DagRun
var dagRunResponse airflow.DagRun
dagRunRequest = airflow.DagRun{
Conf: map[string]interface{}{
"workout_id": workout_id,
"workout_path": workout_path,
},
}
dagRunResponse, httpResponse, err := cli.DAGRunApi.PostDagRun(ctx, "workout_dag", dagRunRequest)
if err != nil {
fmt.Println(err, httpResponse)
} else {
fmt.Println(dagRunResponse)
}
}
httpResponse: 400 Bad Request
{
"detail": "Property is read-only - 'dag_id'",
"status": 400,
"title": "Bad Request",
"type": "https://airflow.apache.org/docs/2.0.1/stable-rest-api-ref.html#section/Errors/BadRequest"
}
Model DagRun : dag_id default "", but rest-api can not receive dag_id argument ?
The golang client is behind on latest REST API spec, we need to regenerate the client based on the new openapi spec. I will try to get it updated later this week if no one gets to it.
Any news on this, this is a block for using this client to trigger Dags.
@DrFaust92 when I regenerated the client couple months ago, it didn't fix this issue. There has been a lot of update to our openapi spec since then, do you want to give it a try to see if the new spec fixes the issue?
Ive opened a PR to use the latest version but i dont see it solving this. seems like an upstream issue in the spec.
Yeah, probably a bug in the spec unnecessarily adding dag_id to the payload.
This is still a problem. Are you aware of this problem?
Ive opened the Above PR and tested it, can confirm it works now. as soon as the upstream PR is merged a new version of the api can be generated :D
Upstream PR merged. ill generate new client and open a PR to this repo.