Skip to content

Commit 543aab8

Browse files
authored
ref(asgi)!: Drop send_default_pii support when setting user IP address (#7818)
Always gate the `user.ip_address` span attribute on `data_collection["user_info"]` instead of falling back to `send_default_pii` when `data_collection` isn't enabled. Update the FastAPI form-data test to use `data_collection` rather than `send_default_pii`. Refs PY-2798 Refs #7566
1 parent 6cbc1fd commit 543aab8

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎sentry_sdk/integrations/asgi.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from sentry_sdk.integrations._wsgi_common import (
2727
DEFAULT_HTTP_METHODS_TO_CAPTURE,
2828
)
29-
from sentry_sdk.scope import Scope, should_send_default_pii
29+
from sentry_sdk.scope import Scope
3030
from sentry_sdk.sessions import track_session
3131
from sentry_sdk.traces import (
3232
SegmentNameSource,
@@ -37,7 +37,6 @@
3737
_is_localhost,
3838
capture_internal_exceptions,
3939
event_from_exception,
40-
has_data_collection_enabled,
4140
logger,
4241
reraise,
4342
)
@@ -226,10 +225,7 @@ async def _run_app(
226225
ip = _get_ip(scope)
227226
if ip:
228227
client_options = sentry_sdk.get_client().options
229-
if has_data_collection_enabled(client_options):
230-
if client_options["data_collection"]["user_info"]:
231-
sentry_scope.set_attribute(SPANDATA.USER_IP_ADDRESS, ip)
232-
elif should_send_default_pii():
228+
if client_options["data_collection"]["user_info"]:
233229
sentry_scope.set_attribute(SPANDATA.USER_IP_ADDRESS, ip)
234230

235231
if ty in ("http", "websocket"):

‎tests/integrations/fastapi/test_fastapi.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ async def test_request_info_json_body(sentry_init, capture_items):
169169
async def test_formdata_request_body(sentry_init, capture_items):
170170
sentry_init(
171171
traces_sample_rate=1.0,
172-
send_default_pii=True,
172+
data_collection={},
173173
max_request_body_size="always",
174174
integrations=[StarletteIntegration()],
175175
)

0 commit comments

Comments
 (0)