Skip to content

Commit 2c3e8b2

Browse files
Handle event being None before before_send_(transaction) (#2045)
Co-authored-by: Anton Pirker <[email protected]>
1 parent 16f14ec commit 2c3e8b2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sentry_sdk/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ def _prepare_event(
323323
event = serialize(event)
324324

325325
before_send = self.options["before_send"]
326-
if before_send is not None and event.get("type") != "transaction":
326+
if (
327+
before_send is not None
328+
and event is not None
329+
and event.get("type") != "transaction"
330+
):
327331
new_event = None
328332
with capture_internal_exceptions():
329333
new_event = before_send(event, hint or {})
@@ -336,7 +340,11 @@ def _prepare_event(
336340
event = new_event # type: ignore
337341

338342
before_send_transaction = self.options["before_send_transaction"]
339-
if before_send_transaction is not None and event.get("type") == "transaction":
343+
if (
344+
before_send_transaction is not None
345+
and event is not None
346+
and event.get("type") == "transaction"
347+
):
340348
new_event = None
341349
with capture_internal_exceptions():
342350
new_event = before_send_transaction(event, hint or {})

0 commit comments

Comments
 (0)