8000 Wrap StarletteRequestExtractor in capture_internal_exceptions (#1551) · Flared/sentry-python@89c800b · GitHub
[go: up one dir, main page]

Skip to content

Commit 89c800b

Browse files
authored
Wrap StarletteRequestExtractor in capture_internal_exceptions (getsentry#1551)
Fixes getsentry#1550
1 parent a240248 commit 89c800b

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

sentry_sdk/integrations/starlette.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from sentry_sdk.utils import (
1717
TRANSACTION_SOURCE_ROUTE,
1818
AnnotatedValue,
19+
capture_internal_exceptions,
1920
event_from_exception,
2021
transaction_from_function,
2122
)
@@ -437,28 +438,35 @@ async def extract_request_info(self):
437438
content_length = await self.content_length()
438439
request_info = {} # type: Dict[str, Any]
439440

440-
if _should_send_default_pii():
441-
request_info["cookies"] = self.cookies()
441+
with capture_internal_exceptions():
442+
if _should_send_default_pii():
443+
request_info["cookies"] = self.cookies()
442444

443-
if not request_body_within_bounds(client, content_length):
444-
data = AnnotatedValue(
445-
"",
446-
{"rem": [["!config", "x", 0, content_length]], "len": content_length},
447-
)
448-
else:
449-
parsed_body = await self.parsed_body()
450-
if parsed_body is not None:
451-
data = parsed_body
452-
elif await self.raw_data():
445+
if not request_body_within_bounds(client, content_length):
453446
data = AnnotatedValue(
454447
"",
455-
{"rem": [["!raw", "x", 0, content_length]], "len": content_length},
448+
{
449+
"rem": [["!config", "x", 0, content_length]],
450+
"len": content_length,
451+
},
456452
)
457453
else:
458-
data = None
454+
parsed_body = await self.parsed_body()
455+
if parsed_body is not None:
456+
data = parsed_body
457+
elif await self.raw_data():
458+
data = AnnotatedValue(
459+
"",
460+
{
461+
"rem": [["!raw", "x", 0, content_length]],
462+
"len": content_length,
463+
},
464+
)
465+
else:
466+
data = None
459467

460-
if data is not None:
461-
request_info["data"] = data
468+
if data is not None:
469+
request_info["data"] = data
462470

463471
return request_info
464472

0 commit comments

Comments
 (0)
0