Skip to content

Commit 0ff06c6

Browse files
committed
.
1 parent cba4360 commit 0ff06c6

File tree

9 files changed

+11
-36
lines changed

9 files changed

+11
-36
lines changed

sentry_sdk/integrations/_wsgi_common.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151
)
5252

5353

54-
def should_include_request_body(
55-
client: Optional[sentry_sdk.client.BaseClient], content_length: int
56-
) -> bool:
54+
def should_include_request_body(client: Optional[sentry_sdk.client.BaseClient]) -> bool:
5755
if client is None:
5856
return False
5957

@@ -79,14 +77,12 @@ def extract_into_event(self, event: Event) -> None:
7977
return
8078

8179
data: Optional[Union[AnnotatedValue, Dict[str, Any]]] = None
82-
83-
content_length = self.content_length()
8480
request_info = event.get("request", {})
8581

8682
if should_send_default_pii():
8783
request_info["cookies"] = dict(self.cookies())
8884

89-
if not should_include_request_body(client, content_length):
85+
if not should_include_request_body(client):
9086
data = AnnotatedValue.removed_because_over_size_limit()
9187
else:
9288
# First read the raw body data

sentry_sdk/integrations/aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def get_aiohttp_request_data(request: Request) -> Union[Optional[str], Annotated
366366

367367
if bytes_body is not None:
368368
# we have body to show
369-
if not should_include_request_body(sentry_sdk.get_client(), len(bytes_body)):
369+
if not should_include_request_body(sentry_sdk.get_client()):
370370
return AnnotatedValue.removed_because_over_size_limit()
371371

372372
encoding = request.charset or "utf-8"

sentry_sdk/integrations/ariadne.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,7 @@ def inner(event: Event, hint: dict[str, Any]) -> Event:
120120
if not isinstance(data, dict):
121121
return event
122122

123-
with capture_internal_exceptions():
124-
try:
125-
content_length = int(
126-
(data.get("headers") or {}).get("Content-Length", 0)
127-
)
128-
except (TypeError, ValueError):
129-
return event
130-
131-
if should_send_default_pii() and should_include_request_body(
132-
get_client(), content_length
133-
):
123+
if should_send_default_pii() and should_include_request_body(get_client()):
134124
request_info = event.setdefault("request", {})
135125
request_info["api_target"] = "graphql"
136126
request_info["data"] = data

sentry_sdk/integrations/dramatiq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def extract_into_event(self, event: Event) -> None:
160160
request_info["type"] = "dramatiq"
161161

162162
data: Optional[Union[AnnotatedValue, Dict[str, Any]]] = None
163-
if not should_include_request_body(client, self.content_length()):
163+
if not should_include_request_body(client):
164164
data = AnnotatedValue.removed_because_over_size_limit()
165165
else:
166166
data = self.message_data

sentry_sdk/integrations/starlette.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,7 @@ async def extract_request_info(
598598
return request_info
599599

600600
# Add annotation if body is too big
601-
if content_length and not should_include_request_body(
602-
client, content_length
603-
):
601+
if not should_include_request_body(client):
604602
request_info["data"] = AnnotatedValue.removed_because_over_size_limit()
605603
return request_info
606604

tests/integrations/bottle/test_bottle.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from sentry_sdk import capture_message
88
from sentry_sdk.consts import DEFAULT_MAX_VALUE_LENGTH
99
from sentry_sdk.integrations.bottle import BottleIntegration
10-
from sentry_sdk.serializer import MAX_DATABAG_BREADTH
1110

1211
from sentry_sdk.integrations.logging import LoggingIntegration
1312
from werkzeug.test import Client
@@ -256,9 +255,7 @@ def index():
256255
def test_json_not_truncated(sentry_init, capture_events, app, get_client):
257256
sentry_init(integrations=[BottleIntegration()])
258257

259-
data = {
260-
"key{}".format(i): "value{}".format(i) for i in range(MAX_DATABAG_BREADTH + 10)
261-
}
258+
data = {"key{}".format(i): "value{}".format(i) for i in range(10**4)}
262259

263260
@app.route("/", method="POST")
264261
def index():

tests/integrations/flask/test_flask.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
)
3030
from sentry_sdk.consts import DEFAULT_MAX_VALUE_LENGTH
3131
from sentry_sdk.integrations.logging import LoggingIntegration
32-
from sentry_sdk.serializer import MAX_DATABAG_BREADTH
3332

3433

3534
login_manager = LoginManager()
@@ -459,9 +458,7 @@ def test_json_not_truncated(sentry_init, capture_events, app):
459458
integrations=[flask_sentry.FlaskIntegration()],
460459
)
461460

462-
data = {
463-
"key{}".format(i): "value{}".format(i) for i in range(MAX_DATABAG_BREADTH + 10)
464-
}
461+
data = {"key{}".format(i): "value{}".format(i) for i in range(10**4)}
465462

466463
@app.route("/", methods=["POST"])
467464
def index():

tests/integrations/pure_eval/test_pure_eval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from sentry_sdk import capture_exception, serializer
5+
from sentry_sdk import capture_exception
66
from sentry_sdk.integrations.pure_eval import PureEvalIntegration
77

88

@@ -85,4 +85,4 @@ def foo():
8585
"s",
8686
"events",
8787
}
88-
assert len(frame_vars) == serializer.MAX_DATABAG_BREADTH
88+
assert len(frame_vars) == 99

tests/integrations/pyramid/test_pyramid.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from sentry_sdk import capture_message, add_breadcrumb
1212
from sentry_sdk.consts import DEFAULT_MAX_VALUE_LENGTH
1313
from sentry_sdk.integrations.pyramid import PyramidIntegration
14-
from sentry_sdk.serializer import MAX_DATABAG_BREADTH
1514
from tests.conftest import unpack_werkzeug_response
1615

1716

@@ -211,9 +210,7 @@ def index(request):
211210
def test_json_not_truncated(sentry_init, capture_events, route, get_client):
212211
sentry_init(integrations=[PyramidIntegration()])
213212

214-
data = {
215-
"key{}".format(i): "value{}".format(i) for i in range(MAX_DATABAG_BREADTH + 10)
216-
}
213+
data = {"key{}".format(i): "value{}".format(i) for i in range(10**4)}
217214

218215
@route("/")
219216
def index(request):

0 commit comments

Comments
 (0)