You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fastapi openapi utils.py UserWarning: Duplicate Operation ID for function #56
Multiple Methods on One Route: Using @app.api_route() with multiple methods (e.g., ["GET", "POST"]) can sometimes cause the generator to produce the same ID for both methods in older FastAPI versions.
apparently FastAPI 0.111.0+ has fixes around deterministic ID generation in these cases.
The warnings come from FastAPI's generate_unique_id() not distinguishing between methods when multiple are combined in a single api_route call. Both object_server.py and locator_api.py use @app.api_route("/{bucket}/{key}", methods=['GET', 'HEAD']), which triggers:
UserWarning: Duplicate Operation ID get_object__bucket___key__head for function get_object
UserWarning: Duplicate Operation ID find_object__bucket___key__head for function find_object
Option A — Wait for an upstream FastAPI fix
Tracked in FastAPI issues #4740 and #13175. Fix attempts:
All released versions through 0.136.1 still emit the warning; upgrading alone won't help.
Option B — Fix on our end
Replace the combined api_route with stacked decorators and explicit operation_id values matching openapi.yaml:
# Before (object_server.py line 119, locator_api.py line 51):@app.api_route("/{bucket}/{key}", methods=['GET', 'HEAD'])# After:@app.get("/{bucket}/{key}", operation_id="getObject")@app.head("/{bucket}/{key}", operation_id="headObject")
No function body changes needed. FileResponse and RedirectResponse already strip the body for HEAD responses via Starlette. Warnings disappear and operation IDs align with the hand-maintained spec.
Decision: defer and watch FastAPI #15398. Revisit if it merges or if warnings start blocking tests.
Activity
ctengel commentedon May 22, 2026
Status: deferred — upstream FastAPI bug
The warnings come from FastAPI's
generate_unique_id()not distinguishing between methods when multiple are combined in a singleapi_routecall. Bothobject_server.pyandlocator_api.pyuse@app.api_route("/{bucket}/{key}", methods=['GET', 'HEAD']), which triggers:Option A — Wait for an upstream FastAPI fix
Tracked in FastAPI issues #4740 and #13175. Fix attempts:
api_routeunsupportedAll released versions through 0.136.1 still emit the warning; upgrading alone won't help.
Option B — Fix on our end
Replace the combined
api_routewith stacked decorators and explicitoperation_idvalues matchingopenapi.yaml:No function body changes needed.
FileResponseandRedirectResponsealready strip the body for HEAD responses via Starlette. Warnings disappear and operation IDs align with the hand-maintained spec.Decision: defer and watch FastAPI #15398. Revisit if it merges or if warnings start blocking tests.