Skip to content

[v3-3-test] Return 404 instead of 500 when ti_run cannot find the DagRun (#72890) - #72900

Merged
vatsrahul1001 merged 4 commits into
v3-3-testfrom
backport-a9f6c89-v3-3-test
Sep 11, 2026
Merged

vatsrahul1001 merged 4 commits into
v3-3-testfrom
backport-a9f6c89-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor
  • Return 404 instead of 500 when ti_run cannot find the DagRun

A missing DagRun in the Execution API ti_run route raised a bare
ValueError, which escaped the route's DataError/SQLAlchemyError guards and
surfaced through the app-level catch-all as an opaque 500. A missing
resource should be reported to the caller as a 404, consistent with the
other not-found paths in this route.

  • Update airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py

Co-authored-by: Henry Chen [email protected]

  • Align test with the updated missing-DagRun error message

  • Keep the ti_run 404 test's scalars mock out of fixture setup

Patching Session.scalars as a decorator also mocked it while
create_task_instance built the fixture, so the DAG bulk-write only worked
because the tables were cleared first. Scope the patch to the request
itself, matching the sibling database-error test.


(cherry picked from commit a9f6c89)

Co-authored-by: Pierre Jeambrun [email protected]
Co-authored-by: Henry Chen [email protected]

…Run (#72890)

* Return 404 instead of 500 when ti_run cannot find the DagRun

A missing DagRun in the Execution API ti_run route raised a bare
ValueError, which escaped the route's DataError/SQLAlchemyError guards and
surfaced through the app-level catch-all as an opaque 500. A missing
resource should be reported to the caller as a 404, consistent with the
other not-found paths in this route.

* Update airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py

Co-authored-by: Henry Chen <[email protected]>

* Align test with the updated missing-DagRun error message

* Keep the ti_run 404 test's scalars mock out of fixture setup

Patching Session.scalars as a decorator also mocked it while
create_task_instance built the fixture, so the DAG bulk-write only worked
because the tables were cleared first. Scope the patch to the request
itself, matching the sibling database-error test.

---------
(cherry picked from commit a9f6c89)

Co-authored-by: Pierre Jeambrun <[email protected]>
Co-authored-by: Henry Chen <[email protected]>
@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:task-sdk labels Sep 10, 2026
@vatsrahul1001
vatsrahul1001 marked this pull request as ready for review September 10, 2026 17:24
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.3.2 milestone Sep 10, 2026
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Sep 10, 2026
@vatsrahul1001
vatsrahul1001 merged commit 84cd209 into v3-3-test Sep 11, 2026
70 checks passed
@vatsrahul1001
vatsrahul1001 deleted the backport-a9f6c89-v3-3-test branch September 11, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants