Support Starlette/FastAPI app.host#4157
Merged
sentrivana merged 2 commits intomasterfrom Mar 18, 2025
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #4157 +/- ##
==========================================
+ Coverage 79.57% 79.58% +0.01%
==========================================
Files 141 141
Lines 15711 15714 +3
Branches 2671 2671
==========================================
+ Hits 12502 12506 +4
Misses 2367 2367
+ Partials 842 841 -1
|
szokeasaurusrex
approved these changes
Mar 18, 2025
| return route.path | ||
| except AttributeError: | ||
| # routes added via app.host() won't have a path attribute | ||
| return scope.get("path") |
Member
There was a problem hiding this comment.
[question] could we just use scope.get("path") in all cases, instead? Or, are there times where route.path is defined, but scope.get("path") is not?
Contributor
Author
There was a problem hiding this comment.
I don't know, so I'm opting for the least invasive approach that will only affect host routes to avoid potentially breaking existing functionality.
Member
There was a problem hiding this comment.
Fair enough – I suppose we could look into this as a future improvement but tbh it's probs not worth much effort
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.
In Starlette/FastAPI you're able to create subapps. When using
transaction_style="url"in our integration, this would throw an exception because we try to accessroute.pathto determine the transaction name, butHostroutes have nopathattribute.Closes #2631