-
Notifications
You must be signed in to change notification settings - Fork 562
fix: Read request body after handler so receive stream is not deprived #4832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
885aeaf
37b78cf
ed0f7f7
670863a
66d2dde
ddc6543
f66bcd6
317e46f
28095bd
11366c0
322f5f8
ea3c43c
27ae466
32ea46f
c4e1232
9d0e167
8fe10b5
6daea19
7b7b9d1
6c9bba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
|
||
if TYPE_CHECKING: | ||
from collections.abc import Generator | ||
from typing import Any, Dict, Union | ||
from typing import Any, Dict, Union, Callable | ||
from graphene.language.source import Source # type: ignore | ||
from graphql.execution import ExecutionResult | ||
from graphql.type import GraphQLSchema | ||
|
@@ -48,7 +48,7 @@ def _patch_graphql(): | |
def _sentry_patched_graphql_sync(schema, source, *args, **kwargs): | ||
# type: (GraphQLSchema, Union[str, Source], Any, Any) -> ExecutionResult | ||
scope = sentry_sdk.get_isolation_scope() | ||
scope.add_event_processor(_event_processor) | ||
scope.add_event_processor(_make_event_processor(source)) | ||
|
||
with graphql_span(schema, source, kwargs): | ||
result = old_graphql_sync(schema, source, *args, **kwargs) | ||
|
@@ -75,7 +75,7 @@ async def _sentry_patched_graphql_async(schema, source, *args, **kwargs): | |
return await old_graphql_async(schema, source, *args, **kwargs) | ||
|
||
scope = sentry_sdk.get_isolation_scope() | ||
scope.add_event_processor(_event_processor) | ||
scope.add_event_processor(_make_event_processor(source)) | ||
|
||
with graphql_span(schema, source, kwargs): | ||
result = await old_graphql_async(schema, source, *args, **kwargs) | ||
|
@@ -99,16 +99,21 @@ async def _sentry_patched_graphql_async(schema, source, *args, **kwargs): | |
graphene_schema.graphql = _sentry_patched_graphql_async | ||
|
||
|
||
def _event_processor(event, hint): | ||
# type: (Event, Dict[str, Any]) -> Event | ||
if should_send_default_pii(): | ||
request_info = event.setdefault("request", {}) | ||
request_info["api_target"] = "graphql" | ||
def _make_event_processor(source): | ||
# type: (Any) -> Callable[[Event, dict[str, Any]], Event] | ||
def _event_processor(event, hint): | ||
# type: (Event, Dict[str, Any]) -> Event | ||
if should_send_default_pii(): | ||
request_info = event.setdefault("request", {}) | ||
request_info["api_target"] = "graphql" | ||
request_info["data"] = {"query": source} | ||
|
||
|
||
elif event.get("request", {}).get("data"): | ||
del event["request"]["data"] | ||
elif event.get("request", {}).get("data"): | ||
del event["request"]["data"] | ||
|
||
return event | ||
return event | ||
|
||
return _event_processor | ||
|
||
|
||
@contextmanager | ||
|
Uh oh!
There was an error while loading. Please reload this page.