Skip to content

UI: Fix HTTPException import that turned a 400 into a 500 in ui/dags #67363

Merged
jason810496 merged 1 commit into
apache:mainfrom
dkranchii:fix/ui-dags-http-exception-import
May 23, 2026
Merged

UI: Fix HTTPException import that turned a 400 into a 500 in ui/dags #67363
jason810496 merged 1 commit into
apache:mainfrom
dkranchii:fix/ui-dags-http-exception-import

Conversation

@dkranchii
Copy link
Copy Markdown
Contributor

The ui/dags.py route file imported HTTPException from http.client (the stdlib base class) instead of fastapi. FastAPI's exception handlers only translate fastapi.HTTPException, so the 400-branch in get_latest_run_info (when dag_id == "~") escaped uncaught and the API returned 500 Internal Server Error instead of the intended 400 Bad Request with the documented detail message.

Fix is one line: drop from http.client import HTTPException and add HTTPException to the existing from fastapi import ... line. Added a regression test asserting GET /dags/~/latest_run returns 400 with the expected detail body.

Was generative AI tooling used to co-author this PR?

…g_id="~"

The wrong HTTPException class (http.client.HTTPException, the stdlib base
class) was imported in airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py.
FastAPI's exception handlers only translate fastapi.HTTPException, so the
400 branch in get_latest_run_info propagated as 500 Internal Server Error.
Import HTTPException from fastapi instead and add a regression test.
Copy link
Copy Markdown
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

@jason810496 jason810496 merged commit 113b6fa into apache:main May 23, 2026
143 checks passed
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 23, 2026

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@dkranchii dkranchii deleted the fix/ui-dags-http-exception-import branch May 23, 2026 06:18
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants