Skip to content

Commit 41bc733

Browse files
ref(pyramid): Drop send_default_pii support (#7693)
### Description - `PyramidRequestExtractor` inherits from `RequestExtractor` which still has some `send_default_pii` branching, but this will be fixed in #7616. #### Issues Resolves #7606
1 parent 6b4d3ec commit 41bc733

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

‎sentry_sdk/integrations/pyramid.py‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version
99
from sentry_sdk.integrations._wsgi_common import RequestExtractor
1010
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
11-
from sentry_sdk.scope import should_send_default_pii
1211
from sentry_sdk.traces import SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE
1312
from sentry_sdk.utils import (
1413
capture_internal_exceptions,
1514
ensure_integration_enabled,
1615
event_from_exception,
17-
has_data_collection_enabled,
1816
package_version,
1917
reraise,
2018
)
@@ -92,12 +90,7 @@ def sentry_patched_call_view(
9290

9391
scope = sentry_sdk.get_isolation_scope()
9492

95-
if has_data_collection_enabled(client.options):
96-
if client.options["data_collection"]["user_info"]:
97-
user_id = request.authenticated_userid
98-
if user_id:
99-
scope.set_user({"id": user_id})
100-
elif should_send_default_pii():
93+
if client.options["data_collection"]["user_info"]:
10194
user_id = request.authenticated_userid
10295
if user_id:
10396
scope.set_user({"id": user_id})
@@ -233,12 +226,8 @@ def pyramid_event_processor(event: "Event", hint: "Dict[str, Any]") -> "Event":
233226
PyramidRequestExtractor(request).extract_into_event(event)
234227

235228
client_options = sentry_sdk.get_client().options
236-
if has_data_collection_enabled(client_options):
237-
if client_options["data_collection"]["user_info"]:
238-
with capture_internal_exceptions():
239-
user_info = event.setdefault("user", {})
240-
user_info.setdefault("id", request.authenticated_userid)
241-
elif should_send_default_pii():
229+
230+
if client_options["data_collection"]["user_info"]:
242231
with capture_internal_exceptions():
243232
user_info = event.setdefault("user", {})
244233
user_info.setdefault("id", request.authenticated_userid)

‎tests/integrations/pyramid/test_pyramid.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def errors(request):
9393

9494

9595
def test_has_context(route, get_client, sentry_init, capture_events):
96-
sentry_init(integrations=[PyramidIntegration()])
96+
sentry_init(integrations=[PyramidIntegration()], data_collection={})
9797
events = capture_events()
9898

9999
@route("/context_message/{msg}")
@@ -110,7 +110,6 @@ def hi2(request):
110110
"env": {"SERVER_NAME": "localhost", "SERVER_PORT": "80"},
111111
"headers": {"Host": "localhost"},
112112
"method": "GET",
113-
"query_string": "",
114113
"url": "http://localhost/context_message/yoo",
115114
}
116115
assert event["transaction"] == "hi2"
@@ -182,6 +181,7 @@ def test_large_json_request(
182181
integrations=[PyramidIntegration()],
183182
max_request_body_size="always",
184183
max_value_length=max_value_length,
184+
data_collection={},
185185
)
186186

187187
data = {"foo": {"bar": "a" * (1034)}}
@@ -215,7 +215,7 @@ def index(request):
215215

216216
@pytest.mark.parametrize("data", [{}, []], ids=["empty-dict", "empty-list"])
217217
def test_flask_empty_json_request(sentry_init, capture_events, route, get_client, data):
218-
sentry_init(integrations=[PyramidIntegration()])
218+
sentry_init(integrations=[PyramidIntegration()], data_collection={})
219219

220220
@route("/")
221221
def index(request):
@@ -238,7 +238,11 @@ def index(request):
238238
def test_json_not_truncated_if_max_request_body_size_is_always(
239239
sentry_init, capture_events, route, get_client
240240
):
241-
sentry_init(integrations=[PyramidIntegration()], max_request_body_size="always")
241+
sentry_init(
242+
integrations=[PyramidIntegration()],
243+
max_request_body_size="always",
244+
data_collection={},
245+
)
242246

243247
data = {
244248
"key{}".format(i): "value{}".format(i) for i in range(MAX_DATABAG_BREADTH + 10)
@@ -268,6 +272,7 @@ def test_files_and_form(
268272
integrations=[PyramidIntegration()],
269273
max_request_body_size="always",
270274
max_value_length=max_value_length,
275+
data_collection={},
271276
)
272277

273278
data = {
@@ -403,11 +408,11 @@ def test_error_in_authenticated_userid(
403408
from sentry_sdk.integrations.logging import LoggingIntegration
404409

405410
sentry_init(
406-
send_default_pii=True,
407411
integrations=[
408412
PyramidIntegration(),
409413
LoggingIntegration(event_level=logging.ERROR),
410414
],
415+
data_collection={},
411416
)
412417
logger = logging.getLogger("test_pyramid")
413418

0 commit comments

Comments
 (0)