Add prek hook to enforce HTTPException is imported from fastapi#67367
Open
jason810496 wants to merge 1 commit into
Open
Add prek hook to enforce HTTPException is imported from fastapi#67367jason810496 wants to merge 1 commit into
jason810496 wants to merge 1 commit into
Conversation
Member
Author
|
I expect CI should fail before #67363 get merged. |
73d4eca to
59e987f
Compare
jscheffl
reviewed
May 23, 2026
Contributor
There was a problem hiding this comment.
I'd propose to keep the check general where it is but making the prek entries into the specific subfolders. e.g. the core things into /airflow-core/.pre-commit-config.yaml
jscheffl
reviewed
May 23, 2026
| ^airflow-core/tests/unit/api_fastapi/.*\.py$| | ||
| ^providers/amazon/(src|tests)/.*\.py$| | ||
| ^providers/common/ai/(src|tests)/.*\.py$| | ||
| ^providers/edge3/(src|tests)/.*\.py$| |
Contributor
There was a problem hiding this comment.
That check willr aise false-positives. Edge containes both client and server sides.
All code in providers/edge3/src/airflow/providers/edge3/worker_api and providers/edge3/src/airflow/providers/edge3/plugins is the API/Server side but in providers/edge3/src/airflow/providers/edge3/cli is is the client (where the FastAPI import will be wrong!)
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?