Skip to content

triggering a dagRun via the API with logical_date=null results in a 500 internal server error #47130

@melugoyal

Description

@melugoyal

Apache Airflow version

main (development)

If "Other Airflow 2 version" selected, which one?

No response

What happened?

version is 3.0.0a4 (not listed in the version dropdown)

curl localhost:9091/public/dags/etl_dag/dagRuns -XPOST -d '{"dag_run_id": "mgdemo_96", "logical_date": null}' -H "Content-Type: application/json"
Internal Server Error

same API request with a non-null logical date succeeds:

curl localhost:9091/public/dags/etl_dag/dagRuns -XPOST -d '{"dag_run_id": "mgdemo_96", "logical_date": "2025-02-18T12:00:00Z"}' -H "Content-Type: application/json"
{"dag_run_id":"mgdemo_96","dag_id":"etl_dag","logical_date":"2025-02-18T12:00:00Z","queued_at":"2025-02-27T00:05:19.465549Z","start_date":null,"end_date":null,"data_interval_start":"2025-02-18T12:00:00Z","data_interval_end":"2025-02-18T12:00:00Z","run_after":"2025-02-18T12:00:00Z","last_scheduling_decision":null,"run_type":"manual","state":"queued","external_trigger":true,"triggered_by":"rest_api","conf":{},"note":null}

stack trace:

INFO:     127.0.0.1:40566 - "POST /public/dags/etl_dag/dagRuns HTTP/1.1" 500 Internal Server Error

ERROR:    Exception in ASGI application

  + Exception Group Traceback (most recent call last):

  |   File "/usr/local/lib/python3.10/site-packages/starlette/_utils.py", line 76, in collapse_excgroups

  |     yield

  |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 178, in __call__

  |     async with anyio.create_task_group() as task_group:

  |   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 767, in __aexit__

  |     raise BaseExceptionGroup(

  | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)

  +-+---------------- 1 ----------------

    | Traceback (most recent call last):

    |   File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi

    |     result = await app(  # type: ignore[func-returns-value]

    |   File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__

    |     await super().__call__(scope, receive, send)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__

    |     await self.middleware_stack(scope, receive, send)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in __call__

    |     raise exc

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in __call__

    |     await self.app(scope, receive, _send)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 22, in __call__

    |     await self.app(scope, receive, send)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in __call__

    |     await self.app(scope, receive, send)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 177, in __call__

    |     with recv_stream, send_stream, collapse_excgroups():

    |   File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__

    |     self.gen.throw(typ, value, traceback)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/_utils.py", line 82, in collapse_excgroups

    |     raise exc

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 179, in __call__

    |     response = await self.dispatch_func(request, call_next)

    |   File "/usr/local/lib/python3.10/site-packages/airflow/api_fastapi/core_api/middleware.py", line 28, in dispatch

    |     response = await call_next(request)

    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 155, in call_next

    |     raise RuntimeError("No response returned.")

    | RuntimeError: No response returned.

    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi

    result = await app(  # type: ignore[func-returns-value]

  File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__

    await super().__call__(scope, receive, send)

  File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__

    await self.middleware_stack(scope, receive, send)

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in __call__

    raise exc

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in __call__

    await self.app(scope, receive, _send)

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 22, in __call__

    await self.app(scope, receive, send)

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in __call__

    await self.app(scope, receive, send)

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 177, in __call__

    with recv_stream, send_stream, collapse_excgroups():

  File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__

    self.gen.throw(typ, value, traceback)

  File "/usr/local/lib/python3.10/site-packages/starlette/_utils.py", line 82, in collapse_excgroups

    raise exc

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 179, in __call__

    response = await self.dispatch_func(request, call_next)

  File "/usr/local/lib/python3.10/site-packages/airflow/api_fastapi/core_api/middleware.py", line 28, in dispatch

    response = await call_next(request)

  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 155, in call_next

    raise RuntimeError("No response returned.")

RuntimeError: No response returned.

What you think should happen instead?

endpoint should return 200 and create the dag run

How to reproduce

repro steps are above

Operating System

api server is on debian 12 bookworm

Versions of Apache Airflow Providers

No response

Deployment

Astronomer

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 APIarea:corekind:bugThis is a clearly a bugpending-responsepriority:highHigh priority bug that should be patched quickly but does not require immediate new release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions