question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trigger a DAG Run via the Stable REST API fails with Bad Request due to external_trigger is set

See original GitHub issue

Apache Airflow version:

2.0.0

Environment:

  • Cloud provider or hardware configuration: OpenStack -> VM -> Docker container
  • OS (e.g. from /etc/os-release): Debian GNU/Linux 10 (buster)
  • Kernel (e.g. uname -a): Linux 77f8efd77516 4.4.0-193-generic #224-Ubuntu

What happened:

I am trying to trigger a DAG run via the new stable REST-API 1.0.0 by using a Java-based client. The Java client is generated from the Airflow OpenAPI specification with OpenAPI generator version 5.0.0 .

In Airflow I have one active DAG demo

I trigger the DAG execution via the java client with the following code snippet:

ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://1.2.3.4:8080/api/v1);
DagRunApi dagRunApi = new DagRunApi(defaultClient);
DAGRun dagRun = new DAGRun();
try {
      DAGRun result = dagRunApi.postDagRun("demo", dagRun);

      LOGGER.debug(result);

    } catch (ApiException e) {
      e.printStackTrace();
    }

However, I receive the following exception:

BAD REQUEST

What you expected to happen:

By checking the airflow logs it turned out that the external_trigger value of the DAGRun is set but this is actually a read-only value and not allowed to be set which results in the BAD REQUEST response.

Adding the nullable: true setting to the external_trigger and recreating the java client resolved the issue!

external_trigger:
          type: boolean
          nullable: true
          readOnly: true

How to reproduce it:

Create the Java client (probably any client will produce this error) via OpenAPI generator:

  1. java -jar codegen/openapi-generator-cli-5.0.0.jar generate -i openapi.yaml -g java -o .
  2. create a simple java class and apply the code snippets from above

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mik-lajcommented, Jan 21, 2021
0reactions
mik-lajcommented, Jan 21, 2021

Just out of curiosity, did you test the postDagRun call with the Airflow go client?

@houqp Can you check it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apache Airflow 2.0.0 Trigger a DAG Run via the Stable REST ...
I am trying to trigger a DAG run via the new stable REST-API 1.0.0 by using a Java-based client. The Java client is...
Read more >
Airflow REST API
BadRequest. This response means that the server cannot or will not process the request due to something that is perceived to be a...
Read more >
Trigger Airflow DAGs via the REST API | Enrollment Nerdery
Step 1 - Enable the REST API. By default, airflow does not accept requests made to the API. However, it's easy enough to...
Read more >
Webhooks - GitLab Docs
Trigger continuous integration (CI) jobs, update external issue trackers, update a backup ... You can define URL variables directly using the REST API....
Read more >
Apache Airflow for Data Science - How to Work with REST APIs
Why? The reason is simple - by dividing the logic into two tasks (one checks if the API is available and the other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found