Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,37 +1828,37 @@
)

for error_processor in error_processors:
new_event = None
new_event = event
with capture_internal_exceptions():
new_event = error_processor(event, exc_info)
if new_event is None:
return self._drop(error_processor, "error processor")

event = new_event

return event

def run_event_processors(self, event: "Event", hint: "Hint") -> "Optional[Event]":
"""
Runs the event processors on the event and returns the modified event.
"""
ty = event.get("type")
is_check_in = ty == "check_in"

if not is_check_in:
# Get scopes without creating them to prevent infinite recursion
isolation_scope = _isolation_scope.get()
current_scope = _current_scope.get()

event_processors = chain(
global_event_processors,
_global_scope and _global_scope._event_processors or [],
isolation_scope and isolation_scope._event_processors or [],
current_scope and current_scope._event_processors or [],
)

for event_processor in event_processors:
new_event = None
new_event = event

Check warning on line 1861 in sentry_sdk/scope.py

View check run for this annotation

@sentry/warden / warden: code-review

Processor exceptions lack regression coverage

Please add `@pytest.mark.tests_internal_exceptions` tests showing that raising error and event processors leave the event available to send. The existing explicit-`None` drop test covers event processors, but not error processors; please cover that path too.
Comment thread
sentrivana marked this conversation as resolved.
with capture_internal_exceptions():
new_event = event_processor(event, hint)
if new_event is None:
Expand Down
43 changes: 0 additions & 43 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,49 +768,6 @@ def foo(event, hint):
sentry_sdk.scope.global_event_processors = old_processors


@pytest.mark.tests_internal_exceptions
def test_event_processor_exception_drops_event_and_records_client_report(
sentry_init, capture_events, capture_record_lost_event_calls
):
sentry_init(default_integrations=False)
events = capture_events()
record_lost_event_calls = capture_record_lost_event_calls()

scope = sentry_sdk.get_isolation_scope()

@scope.add_event_processor
def bad_processor(event, hint):
raise ValueError("processor error")

capture_message("should be dropped")

assert len(events) == 0
assert ("event_processor", "error", None, 1) in record_lost_event_calls


@pytest.mark.tests_internal_exceptions
def test_error_processor_exception_drops_event(
sentry_init, capture_events, capture_record_lost_event_calls
):
sentry_init(default_integrations=False)
events = capture_events()
record_lost_event_calls = capture_record_lost_event_calls()

scope = sentry_sdk.get_isolation_scope()

@scope.add_error_processor
def bad_error_processor(event, exc_info):
raise ValueError("error processor error")

try:
raise ValueError("original error")
except Exception:
capture_exception()

assert len(events) == 0
assert ("event_processor", "error", None, 1) in record_lost_event_calls


@pytest.mark.tests_internal_exceptions
def test_before_send_exception_records_callback_error(
sentry_init, capture_events, capture_record_lost_event_calls
Expand Down
Loading