Skip to content

Commit ae3ad30

Browse files
committed
forgot to move setting of a url.query behind the pii check
1 parent a07b0be commit ae3ad30

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

sentry_sdk/integrations/aiohttp.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,7 @@ async def sentry_app_handle(
159159
header_value
160160
)
161161

162-
url_attributes = (
163-
{"url.query": request.query_string}
164-
if request.query_string
165-
else {}
166-
)
167-
162+
url_attributes = {}
168163
if should_send_default_pii():
169164
url_attributes["url.full"] = "%s://%s%s" % (
170165
request.scheme,
@@ -173,6 +168,9 @@ async def sentry_app_handle(
173168
)
174169
url_attributes["url.path"] = request.path
175170

171+
if request.query_string:
172+
url_attributes["url.query"] = request.query_string
173+
176174
client_address_attributes = {}
177175
if should_send_default_pii() and request.remote:
178176
client_address_attributes["client.address"] = request.remote

tests/integrations/aiohttp/test_aiohttp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,12 +1296,14 @@ async def hello(request):
12961296

12971297

12981298
@pytest.mark.asyncio
1299+
@pytest.mark.parametrize("send_pii", [True, False])
12991300
async def test_url_query_attribute_span_streaming(
1300-
sentry_init, aiohttp_client, capture_items
1301+
sentry_init, aiohttp_client, capture_items, send_pii
13011302
):
13021303
sentry_init(
13031304
integrations=[AioHttpIntegration()],
13041305
traces_sample_rate=1.0,
1306+
send_default_pii=send_pii,
13051307
_experiments={"trace_lifecycle": "stream"},
13061308
)
13071309

@@ -1322,7 +1324,10 @@ async def hello(request):
13221324
assert len(items) == 2
13231325
server_segment, client_segment = [item.payload for item in items]
13241326

1325-
assert server_segment["attributes"]["url.query"] == "foo=bar&baz=qux"
1327+
if send_pii:
1328+
assert server_segment["attributes"]["url.query"] == "foo=bar&baz=qux"
1329+
else:
1330+
assert "url.query" not in server_segment["attributes"]
13261331

13271332

13281333
@pytest.mark.asyncio

0 commit comments

Comments
 (0)