Skip to content

Commit cd39b28

Browse files
merge
2 parents c937102 + f5ef1a3 commit cd39b28

2 files changed

Lines changed: 3 additions & 11 deletions

File tree

sentry_sdk/integrations/starlette.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,8 @@ def _get_cached_request_body_attribute(
486486
if content_length and not request_body_within_bounds(client, content_length):
487487
return OVER_SIZE_LIMIT_SUBSTITUTE
488488

489-
json_body = getattr(request, "_json", None)
490-
if json_body is not None:
491-
return json.dumps(json_body)
489+
if hasattr(request, "_json"):
490+
return json.dumps(request._json)
492491

493492
formdata_body = getattr(request, "_form", None)
494493
if formdata_body is None:
@@ -506,7 +505,7 @@ async def _wrap_async_handler(
506505
handler: "Callable[..., Awaitable[Any]]", *args: "Any", **kwargs: "Any"
507506
) -> "Any":
508507
"""
509-
Wraps an asynchronous handler function to attach request info to the server segment span.
508+
Wraps an asynchronous handler function to attach request info to errors and the server segment span.
510509
The request body cached on the Starlette Request object is attached to streamed spans, but consuming the request body in the event
511510
processor can still cause application hangs.
512511
"""

tests/integrations/fastapi/test_fastapi.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from fastapi import Body, FastAPI, File, Form, HTTPException, Request, UploadFile
1313
from fastapi.middleware.trustedhost import TrustedHostMiddleware
1414
from fastapi.testclient import TestClient
15-
from starlette.responses import JSONResponse
1615

1716
import sentry_sdk
1817
from sentry_sdk import capture_message
@@ -110,12 +109,6 @@ async def body_form(
110109
capture_message("hi")
111110
return {"status": "ok"}
112111

113-
@app.post("/body/raw")
114-
async def body_raw(request: Request):
115-
await request.body()
116-
capture_message("hi")
117-
return JSONResponse({"status": "ok"})
118-
119112
return app
120113

121114

0 commit comments

Comments
 (0)