From f5c3a26e8159fb809220446ed61a99ac04768389 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Mon, 10 Aug 2026 15:00:05 -0400 Subject: [PATCH 1/3] test(django): Prune duplicate rows from test_asgi_request_body The send_default_pii dimension held every row to the same outcome: none of the expected_data values differ between the pii=True and pii=False halves of the table, so the 5 pii=False rows re-ran the assertions of their pii=True counterparts. Drop them and the now-constant dimension. Also drop the application/xml row, which exercises the same "no structured body" branch as the text/plain row already in the table. --- tests/integrations/django/asgi/test_asgi.py | 60 +-------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index 9abf52b120..3028a6153e 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -668,10 +668,9 @@ async def test_trace_from_headers_if_performance_disabled( @pytest.mark.parametrize("application", APPS) @pytest.mark.parametrize( - "send_default_pii,method,headers,url_name,body,expected_data", + "method,headers,url_name,body,expected_data", [ ( - True, "POST", [(b"content-type", b"text/plain")], "post_echo_async", @@ -679,7 +678,6 @@ async def test_trace_from_headers_if_performance_disabled( None, ), ( - True, "POST", [(b"content-type", b"text/plain")], "post_echo_async", @@ -687,7 +685,6 @@ async def test_trace_from_headers_if_performance_disabled( "", ), ( - True, "POST", [(b"content-type", b"application/json")], "post_echo_async", @@ -695,58 +692,6 @@ async def test_trace_from_headers_if_performance_disabled( {"username": "xyz", "password": "[Filtered]"}, ), ( - True, - "POST", - [(b"content-type", b"application/xml")], - "post_echo_async", - b'', - "", - ), - ( - True, - "POST", - [ - (b"content-type", b"multipart/form-data; boundary=fd721ef49ea403a6"), - (b"content-length", BODY_FORM_CONTENT_LENGTH), - ], - "post_echo_async", - BODY_FORM, - {"password": "[Filtered]", "photo": "", "username": "Jane"}, - ), - ( - False, - "POST", - [(b"content-type", b"text/plain")], - "post_echo_async", - b"", - None, - ), - ( - False, - "POST", - [(b"content-type", b"text/plain")], - "post_echo_async", - b"some raw text body", - "", - ), - ( - False, - "POST", - [(b"content-type", b"application/json")], - "post_echo_async", - b'{"username":"xyz","password":"xyz"}', - {"username": "xyz", "password": "[Filtered]"}, - ), - ( - False, - "POST", - [(b"content-type", b"application/xml")], - "post_echo_async", - b'', - "", - ), - ( - False, "POST", [ (b"content-type", b"multipart/form-data; boundary=fd721ef49ea403a6"), @@ -768,7 +713,6 @@ async def test_asgi_request_body( capture_envelopes, capture_items, application, - send_default_pii, method, headers, url_name, @@ -778,7 +722,7 @@ async def test_asgi_request_body( ): sentry_init( integrations=[DjangoIntegration()], - send_default_pii=send_default_pii, + send_default_pii=True, trace_lifecycle="stream" if span_streaming else "static", ) From d4e7586055134c35a2e930eb9dccd3eeb588b39e Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Mon, 10 Aug 2026 15:00:05 -0400 Subject: [PATCH 2/3] test(django): Drop middleware_spans parametrize from test_active_thread_id The arm only toggled creation of middleware spans, which this test never inspects: the streaming path skips non-segment spans, and the static path looks at profile and transaction items. Both DjangoIntegration(middleware_spans=) settings remain covered by the dedicated middleware-span tests. --- tests/integrations/django/asgi/test_asgi.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index 3028a6153e..b5c419ebe5 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -199,7 +199,6 @@ async def test_async_views( @pytest.mark.parametrize("application", APPS) @pytest.mark.parametrize("endpoint", ["/sync/thread_ids", "/async/thread_ids"]) -@pytest.mark.parametrize("middleware_spans", [False, True]) @pytest.mark.asyncio @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" @@ -212,11 +211,10 @@ async def test_active_thread_id( teardown_profiling, endpoint, application, - middleware_spans, span_streaming, ): sentry_init( - integrations=[DjangoIntegration(middleware_spans=middleware_spans)], + integrations=[DjangoIntegration()], traces_sample_rate=1.0, profiles_sample_rate=1.0, trace_lifecycle="stream" if span_streaming else "static", From 05ce4f084064b28da5d7dabbb33cdf6fee1217b4 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Mon, 10 Aug 2026 15:00:05 -0400 Subject: [PATCH 3/3] test(django): Use a local case table for the ASGI user identity test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_user_identity_error_event_data_collection borrowed the shared 6-row DATA_COLLECTION_USER_INFO_CASES table, 2 rows of which cover send_default_pii vs. data_collection precedence — already asserted by the WSGI tests in test_data_scrubbing.py. Replace it with a local 4-row table covering the branches asgi.py actually takes: pii on/off crossed with data_collection user_info on/off. --- tests/integrations/django/asgi/test_asgi.py | 23 +++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index b5c419ebe5..c825340792 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -17,7 +17,6 @@ from sentry_sdk.integrations.django.asgi import _asgi_middleware_mixin_factory from tests.integrations.django.myapp.asgi import channels_application from tests.integrations.django.utils import pytest_mark_django_db_decorator -from tests.integrations.utils import DATA_COLLECTION_USER_INFO_CASES try: from django.urls import reverse @@ -1046,7 +1045,27 @@ async def test_async_middleware_process_exception_is_awaited( @pytest.mark.skipif( django.VERSION < (3, 0), reason="Django ASGI support shipped in 3.0" ) -@pytest.mark.parametrize("init_kwargs, expect_user", DATA_COLLECTION_USER_INFO_CASES) +# The full precedence table (data_collection winning over send_default_pii) +# is covered by the WSGI tests in test_data_scrubbing.py; here we only need +# each user-info branch of the ASGI middleware: legacy pii on/off and +# data_collection user_info on/off (asgi.py:75-83, _asgi_common.py:129-143). +@pytest.mark.parametrize( + "init_kwargs, expect_user", + [ + pytest.param({"send_default_pii": True}, True, id="pii_on"), + pytest.param({"send_default_pii": False}, False, id="pii_off"), + pytest.param( + {"_experiments": {"data_collection": {"user_info": True}}}, + True, + id="data_collection_user_info_on", + ), + pytest.param( + {"_experiments": {"data_collection": {"user_info": False}}}, + False, + id="data_collection_user_info_off", + ), + ], +) @pytest_mark_django_db_decorator() async def test_user_identity_error_event_data_collection( sentry_init, capture_events, application, init_kwargs, expect_user