Skip to content

Commit bb5abb0

Browse files
committed
fix: Event processors always get a Hint
1 parent 8ffdc19 commit bb5abb0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

sentry_sdk/client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def _prepare_event(
105105
if event.get("timestamp") is None:
106106
event["timestamp"] = datetime.utcnow()
107107

108+
hint = dict(hint or ()) # type: Hint
109+
108110
if scope is not None:
109111
event = scope.apply_to_event(event, hint)
110112
if event is None:
@@ -153,7 +155,7 @@ def _prepare_event(
153155
if before_send is not None:
154156
new_event = None
155157
with capture_internal_exceptions():
156-
new_event = before_send(event, hint)
158+
new_event = before_send(event, hint or {})
157159
if new_event is None:
158160
logger.info("before send dropped event (%s)", event)
159161
event = new_event # type: ignore

sentry_sdk/scope.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ def func(event, exc_info):
170170
self._error_processors.append(func)
171171

172172
@_disable_capture
173-
def apply_to_event(self, event, hint=None):
174-
# type: (Event, Optional[Hint]) -> Optional[Event]
173+
def apply_to_event(self, event, hint):
174+
# type: (Event, Hint) -> Optional[Event]
175175
"""Applies the information contained on the scope to the given event."""
176176

177177
def _drop(event, cause, ty):
@@ -207,7 +207,7 @@ def _drop(event, cause, ty):
207207
"span_id": self._span.span_id,
208208
}
209209

210-
exc_info = hint.get("exc_info") if hint is not None else None
210+
exc_info = hint.get("exc_info")
211211
if exc_info is not None:
212212
for error_processor in self._error_processors:
213213
new_event = error_processor(event, exc_info)

sentry_sdk/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Breadcrumb = Dict[str, Any]
3333
BreadcrumbHint = Dict[str, Any]
3434

35-
EventProcessor = Callable[[Event, Optional[Hint]], Optional[Event]]
35+
EventProcessor = Callable[[Event, Hint], Optional[Event]]
3636
ErrorProcessor = Callable[[Event, ExcInfo], Optional[Event]]
3737
BreadcrumbProcessor = Callable[[Breadcrumb, BreadcrumbHint], Optional[Breadcrumb]]
3838

0 commit comments

Comments
 (0)