Fix handling root_path#81
Merged
stephenhillier merged 1 commit intostephenhillier:masterfrom Jan 6, 2024
Merged
Conversation
138fb64 to
8288cba
Compare
This was referenced Dec 23, 2023
Owner
|
@dolfinus thanks for the PR. This looks like a good solution. For the new base path test, it looks like route matching is failing - |
Contributor
Author
|
This test is failing on starlette<0.33 because of Kludex/starlette#2352. Added condition here. It is possible to update minimal version of starlette to fix this, but FastAPI still does not support this version: fastapi/fastapi#10798 |
Owner
|
Thank you! Really appreciate the contribution and explanation. |
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.
uvicorn --root-path=/api. Fixes filter_unhandled_paths broken with root_path set via Uvicorn #75.Previously
PrometheusMiddlewarejust threw awayroot_pathfrom request scope. Because of this,_get_router_pathalways returnedNone, and ifPrometheusMiddlewarewas used with bothgroup_paths=Trueandfilter_unhandled_paths=True, all application endpoints were just excluded from monitoring.This requires
statlette>=0.33because of Kludex/starlette#2352.__call__method was implemented like this:But if the finally clause executes a return statement, exceptions are not re-raised. So bug from item 1 prevented unhandled exceptions from being raised properly. This caused some unexpected log messages, like this:
Simple application
I've just removed
finallyblock:Fixes #80.
root_pathwith failing endpoints and not, with enabledfilter_unhandled_pathsand not, to cover all possible cases. Also rearranged few tests a bit.