Skip to content

Handle event being None before before_send_(transaction) #2045

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

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ def _prepare_event(
event = serialize(event)

before_send = self.options["before_send"]
if before_send is not None and event.get("type") != "transaction":
if (
before_send is not None
and event is not None
and event.get("type") != "transaction"
):
new_event = None
with capture_internal_exceptions():
new_event = before_send(event, hint or {})
Expand All @@ -336,7 +340,11 @@ def _prepare_event(
event = new_event # type: ignore

before_send_transaction = self.options["before_send_transaction"]
if before_send_transaction is not None and event.get("type") == "transaction":
if (
before_send_transaction is not None
and event is not None
and event.get("type") == "transaction"
):
new_event = None
with capture_internal_exceptions():
new_event = before_send_transaction(event, hint or {})
Expand Down