Keep OpenAPI error responses in sync with the statuses routes raise - #71647
Open
Pushkal-Gupta wants to merge 1 commit into
Open
Keep OpenAPI error responses in sync with the statuses routes raise#71647Pushkal-Gupta wants to merge 1 commit into
Pushkal-Gupta wants to merge 1 commit into
Conversation
`create_openapi_http_exception_doc(...)` feeds the `responses=` block that the generated spec — and every client built from it — uses to model error responses, but nothing ties that list to the statuses a handler actually raises. The two drift apart silently, and the same drift has had to be found and patched by hand four times (apache#67570, apache#67571, apache#70992, apache#71011). A static check keeps them together, so the next divergence fails in CI instead of shipping a spec that omits a response the API really returns.
Pushkal-Gupta
requested review from
amoghrajesh,
ashb,
bbovenzi,
bugraoz93,
choo121600,
ephraimbuddy,
gopidesupavan,
guan404ming,
henry3260,
jason810496,
jscheffl,
kaxil,
pierrejeambrun,
potiuk,
rawwar,
ryanahamilton,
shubhamraj-git and
vatsrahul1001
as code owners
August 15, 2026 04:40
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
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.
Follow-up to #67570, #67571, #70992 and #71011, which each found and patched instances of
the same drift by hand: a route handler raises an HTTP status that
create_openapi_http_exception_doc(...)never declares, so the generated spec — and everyclient built from it — has no model for a response the API really returns.
The helper's own docstring names the problem:
This adds the check that makes it automatic, so the next divergence fails in CI instead of
shipping. Running it over
api_fastapi/**/routes/found 15 statuses still undeclared afterthe four manual passes:
POST /connections/test400GET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{try_number}400POST /variables404GET /ui/next_run_assets/{dag_id}404GET /ui/partitioned_dag_runs404dag_idthat does not existGET /ui/pending_partitioned_dag_run/{dag_id}404GET /ui/teams403GET /execution/asset-events/by-asset400namenoruriis suppliedGET /execution/store/asset/by-name/value404GET /execution/store/asset/by-uri/value404PATCH /execution/hitlDetails/{task_instance_id}409PATCH /execution/task-instances/{task_instance_id}/run500GET /execution/store/ti/{task_instance_id}/{key}404HEAD /execution/xcoms/{dag_id}/{run_id}/{task_id}/{key}400map_indexis passed to a HEAD requestPOST /execution/xcoms/{dag_id}/{run_id}/{task_id}/{key}400The regenerated spec and UI client show the effect: seven public/UI endpoints gain error
models their clients previously had no type for.
About the check
It is deliberately conservative — it is meant to be trustworthy enough to gate CI, so it
under-reports rather than over-reports, and stays silent whenever it cannot see the whole
picture:
HTTPException(...)raised in the handler's own body counts. Statuses raised by ashared dependency or a service helper are not required to be declared.
422is never required (FastAPI documents validation errors itself), and neither are401/403— routers contribute those wholesale via their auth dependencies, and therouter that does so is often built in another module (
routes/public/__init__.pydeclares both for every public route).
responses=onAPIRouter(...)(as inexecution_api/routes/xcoms.py) counts as declared.responses=blocks that are not aliteral
create_openapi_http_exception_doc([...])call or mapping, are skipped ratherthan guessed at.
The
GET /ui/teams403above sits outside what the check enforces, for the401/403reason just described; it is included because it is a real gap in
_private_ui.yamlthatthe same audit turned up.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines