Add prek hook to enforce HTTPException is imported from fastapi#67367
Open
jason810496 wants to merge 2 commits into
Open
Add prek hook to enforce HTTPException is imported from fastapi#67367jason810496 wants to merge 2 commits into
jason810496 wants to merge 2 commits into
Conversation
Member
Author
|
I expect CI should fail before #67363 get merged. |
73d4eca to
59e987f
Compare
jscheffl
reviewed
May 23, 2026
jscheffl
reviewed
May 23, 2026
Splits the single root-level hook entry into per-distribution `.pre-commit-config.yaml` files (airflow-core, providers/amazon, providers/common/ai, providers/edge3, providers/fab, providers/keycloak). Each entry is scoped to the subtree that actually wires a FastAPI app, so edge3's `cli/` (client) is excluded and only `worker_api/` and `plugins/` are checked. Also fixes a latent bug the hook caught in `airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py`, where `HTTPException` was imported from `http.client` and called with FastAPI's `(status_code, detail)` signature -- the route would return 500 instead of the intended 400 for `dag_id == "~"`.
59e987f to
49e36b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
fastapi.HTTPException,starlette.exceptions.HTTPException, andhttp.client.HTTPExceptionare three different classes — mixing them silently breaksisinstance/pytest.raiseschecks, andhttp.client.HTTPExceptionhas a different constructor so routes return 500 instead of the intended status (the exact bug #67363 fixed incore_api/routes/ui/dags.py).What
scripts/ci/prek/check_http_exception_import_from_fastapi.py— an AST-based prek hook that flags anyfrom <module> import HTTPExceptionwhere<module>is notfastapi(or afastapi.*submodule)..pre-commit-config.yaml, scoped to the FastAPI-using trees:airflow-core/src/airflow/api_fastapi/,airflow-core/tests/unit/api_fastapi/, and thesrc/+tests/of the providers that wire FastAPI apps (amazon,common/ai,edge3,fab,keycloak).Was generative AI tooling used to co-author this PR?