Skip to content

Commit 8d6f154

Browse files
authored
ref(strawberry)!: Drop send_default_pii support in request data (#7869)
The request event processor now reads only the `data_collection` options for the GraphQL document and variables, and no longer falls back to `send_default_pii`. It also no longer removes `request.data` when neither option is set, so a body attached by the web framework integration is left untouched (as the attaching of the body is controlled by the `http_bodies` property in the `data_collection` settings) Fixes PY-2843 Fixes #7614
1 parent 22cf597 commit 8d6f154

2 files changed

Lines changed: 54 additions & 210 deletions

File tree

‎sentry_sdk/integrations/strawberry.py‎

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -365,50 +365,29 @@ def _make_request_event_processor(
365365
def inner(event: "Event", hint: "dict[str, Any]") -> "Event":
366366
client_options = sentry_sdk.get_client().options
367367
with capture_internal_exceptions():
368-
if has_data_collection_enabled(client_options):
369-
request_data = event.setdefault("request", {})
370-
if client_options["data_collection"]["graphql"]["document"]:
371-
request_data["api_target"] = "graphql"
372-
373-
if not request_data.get("data"):
374-
execution_context_data: "dict[str, Any]" = (
375-
{"query": execution_context.query}
376-
if client_options["data_collection"]["graphql"]["document"]
377-
else {}
378-
)
379-
380-
if (
381-
client_options["data_collection"]["graphql"]["variables"]
382-
and execution_context.variables
383-
):
384-
execution_context_data["variables"] = (
385-
execution_context.variables
386-
)
387-
388-
if execution_context.operation_name:
389-
execution_context_data["operationName"] = (
390-
execution_context.operation_name
391-
)
392-
393-
request_data["data"] = execution_context_data
394-
elif should_send_default_pii():
395-
request_data = event.setdefault("request", {})
368+
request_data = event.setdefault("request", {})
369+
if client_options["data_collection"]["graphql"]["document"]:
396370
request_data["api_target"] = "graphql"
397371

398-
if not request_data.get("data"):
399-
data: "dict[str, Any]" = {"query": execution_context.query}
400-
if execution_context.variables:
401-
data["variables"] = execution_context.variables
402-
if execution_context.operation_name:
403-
data["operationName"] = execution_context.operation_name
372+
if not request_data.get("data"):
373+
execution_context_data: "dict[str, Any]" = (
374+
{"query": execution_context.query}
375+
if client_options["data_collection"]["graphql"]["document"]
376+
else {}
377+
)
404378

405-
request_data["data"] = data
379+
if (
380+
client_options["data_collection"]["graphql"]["variables"]
381+
and execution_context.variables
382+
):
383+
execution_context_data["variables"] = execution_context.variables
406384

407-
else:
408-
try:
409-
del event["request"]["data"]
410-
except (KeyError, TypeError):
411-
pass
385+
if execution_context.operation_name:
386+
execution_context_data["operationName"] = (
387+
execution_context.operation_name
388+
)
389+
390+
request_data["data"] = execution_context_data
412391

413392
return event
414393

0 commit comments

Comments
 (0)