|
16 | 16 | from sentry_sdk.utils import (
|
17 | 17 | TRANSACTION_SOURCE_ROUTE,
|
18 | 18 | AnnotatedValue,
|
| 19 | + capture_internal_exceptions, |
19 | 20 | event_from_exception,
|
20 | 21 | transaction_from_function,
|
21 | 22 | )
|
@@ -437,28 +438,35 @@ async def extract_request_info(self):
|
437 | 438 | content_length = await self.content_length()
|
438 | 439 | request_info = {} # type: Dict[str, Any]
|
439 | 440 |
|
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() |
442 | 444 |
|
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): |
453 | 446 | data = AnnotatedValue(
|
454 | 447 | "",
|
455 |
| - {"rem": [["!raw", "x", 0, content_length]], "len": content_length}, |
| 448 | + { |
| 449 | + "rem": [["!config", "x", 0, content_length]], |
| 450 | + "len": content_length, |
| 451 | + }, |
456 | 452 | )
|
457 | 453 | 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 |
459 | 467 |
|
460 |
| - if data is not None: |
461 |
| - request_info["data"] = data |
| 468 | + if data is not None: |
| 469 | + request_info["data"] = data |
462 | 470 |
|
463 | 471 | return request_info
|
464 | 472 |
|
|
0 commit comments