-
Notifications
You must be signed in to change notification settings - Fork 562
fix: Read request body after handler so receive stream is not deprived #4832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: Read request body after handler so receive stream is not deprived #4832
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4832 +/- ##
==========================================
+ Coverage 84.58% 84.83% +0.25%
==========================================
Files 158 158
Lines 16521 16595 +74
Branches 2867 2877 +10
==========================================
+ Hits 13974 14079 +105
+ Misses 1703 1670 -33
- Partials 844 846 +2
|
Closing for the reasons in #4764 (comment) |
Reopening because there may be the option of changing data fields on transactions in a minor version. Users with our FastAPI integration are facing empty receive streams when using |
Description
Ensure endpoint handler runs before the FastAPI or Starlette integrations read the request body.
As the integrations previously called high-level Starlette
Request
methods early, the underlying ASGI receive stream was consumed before the user's handler or middleware ran. While theRequest
object caches the request body, any handler or middleware that relies on low-level stream access still failed.The event handler that sets
request.data
is now registered after the HTTP request is handled. Therequest.data
attribute may no longer be attached to events emitted while the request is processed. In particular, ifNote that
pydantic
also relies on FastAPI/Starlette accessors sorequest.data
may still be available even if the user only implicitly uses the high-level accessors.Issues
Closes #4764
Closes #4827
Closes PY-1851
Closes PY-1831
Reminders
tox -e linters
.feat:
,fix:
,ref:
,meta:
)