Skip to content

Bad request when triggering dag run with note in payload #28825

@ttben

Description

@ttben

Apache Airflow version

2.5.0

What happened

Specifying a note in the payload (as mentioned in the doc) 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

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"
        )
    )

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"
  }' 

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"
}

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"
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions