You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/10 10:53:04 UTC
[GitHub] [airflow] ttben opened a new issue, #28825: Bad request when triggering dag run with `note` in payload
ttben opened a new issue, #28825:
URL: https://github.com/apache/airflow/issues/28825
### Apache Airflow version
2.5.0
### What happened
Specifying a `note` in the payload (as mentioned [in the doc](https://airflow.apache.org/docs/apache-airflow/2.5.0/stable-rest-api-ref.html#operation/post_dag_run)) when triggering a new dag run yield a 400 bad request
(Git Version: .release:2.5.0+fa2bec042995004f45b914dd1d66b466ccced410)
### What you think should happen instead
As far as I understand the documentation, I should be able to set a note for this dag run, and it is not the case.
### How to reproduce
This is a local airflow, using default credentials and default setup when following [this guide](https://airflow.apache.org/docs/apache-airflow/stable/howto/docker-compose/index.html#)
DAG:
<details>
```
import airflow
from airflow import DAG
import logging
from airflow.operators.python import PythonOperator
from airflow.operators.dummy import DummyOperator
from datetime import timedelta
logger = logging.getLogger("airflow.task")
default_args = {
"owner": "airflow",
"depends_on_past": False,
"retries": 0,
"retry_delay": timedelta(minutes=5),
}
def log_body(**context):
logger.info(f"Body: {context['dag_run'].conf}")
with DAG(
"my-validator",
default_args=default_args,
schedule_interval=None,
start_date=airflow.utils.dates.days_ago(0),
catchup=False
) as dag:
(
PythonOperator(
task_id="abcde",
python_callable=log_body,
provide_context=True
)
>> DummyOperator(
task_id="todo"
)
)
```
</details>
Request:
<details>
```
curl --location --request POST '0.0.0.0:8080/api/v1/dags/my-validator/dagRuns' \
--header 'Authorization: Basic YWlyZmxvdzphaXJmbG93' \
--header 'Content-Type: application/json' \
--data-raw '{
"conf": {
"key":"value"
},
"note": "test"
}'
```
</details>
Response:
<details>
```
{
"detail": "{'note': ['Unknown field.']}",
"status": 400,
"title": "Bad Request",
"type": "https://airflow.apache.org/docs/apache-airflow/2.5.0/stable-rest-api-ref.html#section/Errors/BadRequest"
}
```
</details>
Removing the `note` key, returns 200... with a null `note`!
<details>
```
{
"conf": {
"key": "value"
},
"dag_id": "my-validator",
"dag_run_id": "manual__2023-01-10T10:45:26.102802+00:00",
"data_interval_end": "2023-01-10T10:45:26.102802+00:00",
"data_interval_start": "2023-01-10T10:45:26.102802+00:00",
"end_date": null,
"execution_date": "2023-01-10T10:45:26.102802+00:00",
"external_trigger": true,
"last_scheduling_decision": null,
"logical_date": "2023-01-10T10:45:26.102802+00:00",
"note": null,
"run_type": "manual",
"start_date": null,
"state": "queued"
}
```
</details>
### Operating System
Ubuntu 20.04.5 LTS
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else
Everytime.
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ephraimbuddy closed issue #28825: Bad request when triggering dag run with `note` in payload
Posted by "ephraimbuddy (via GitHub)" <gi...@apache.org>.
ephraimbuddy closed issue #28825: Bad request when triggering dag run with `note` in payload
URL: https://github.com/apache/airflow/issues/28825
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] obilalk commented on issue #28825: Bad request when triggering dag run with `note` in payload
Posted by GitBox <gi...@apache.org>.
obilalk commented on issue #28825:
URL: https://github.com/apache/airflow/issues/28825#issuecomment-1387123398
In `v1.yaml` you can see setted get-post request for airflow `/dags/{dag_id}/dagRuns`:
https://github.com/apache/airflow/blob/d5ac1b057f96d94062a92d968fe40f4371eb5da0/airflow/api_connexion/openapi/v1.yaml#L700-L759
`post_dag_run` function is the main function to external trigger for Dag, in this case if dagrun_instance return False start to send payload to trigger airflow dag but there are no exist note section.
https://github.com/apache/airflow/blob/d5ac1b057f96d94062a92d968fe40f4371eb5da0/airflow/api_connexion/endpoints/dag_run_endpoint.py#L308-L325
On the other hand to set a note for DagRun with api call we need dagrun_instance True but it will conflict in `post_dag_run` function.
https://github.com/apache/airflow/blob/d5ac1b057f96d94062a92d968fe40f4371eb5da0/airflow/api_connexion/endpoints/dag_run_endpoint.py#L426-L450
Solution:
-Use note paramater inside of first task so that after triggered dag it will update DagRun notes.
Example : PATCH-->`BASE_URL/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/setNote`
Alternative:
-Contribute new session to combine payload.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on issue #28825: Bad request when triggering dag run with `note` in payload
Posted by GitBox <gi...@apache.org>.
uranusjr commented on issue #28825:
URL: https://github.com/apache/airflow/issues/28825#issuecomment-1383774128
The `note` field is incorrectly marked as `dump_only=True`. Feel free to contribute.
https://github.com/apache/airflow/blob/d5ac1b057f96d94062a92d968fe40f4371eb5da0/airflow/api_connexion/schemas/dag_run_schema.py#L76
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] sc-mitton commented on issue #28825: Bad request when triggering dag run with `note` in payload
Posted by "sc-mitton (via GitHub)" <gi...@apache.org>.
sc-mitton commented on issue #28825:
URL: https://github.com/apache/airflow/issues/28825#issuecomment-1404521932
Hi, I'm trying to become a new contributor to airflow and am looking for a good starter task to get my feet wet. I can't quite tell, but does this task still need someone to work on it? If so, I'd be happy to work on it. Though it might take me a few days to work it out since I'm just getting started contributing (I have been working in airflow for several months at work which is what prompted me to want to do this).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #28825: Bad request when triggering dag run with `note` in payload
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #28825:
URL: https://github.com/apache/airflow/issues/28825#issuecomment-1377071673
Thanks for opening your first issue here! Be sure to follow the issue template!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org