Skip to content

Commit b499d89

Browse files
authored
fix: Keep event if processor raises (#7701)
As this is technically a breaking change and we have a major around the corner, let's do it there. Reverting this change on master.
1 parent a69ac4b commit b499d89

2 files changed

Lines changed: 2 additions & 45 deletions

File tree

‎sentry_sdk/scope.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ def run_error_processors(self, event: "Event", hint: "Hint") -> "Optional[Event]
18281828
)
18291829

18301830
for error_processor in error_processors:
1831-
new_event = None
1831+
new_event = event
18321832
with capture_internal_exceptions():
18331833
new_event = error_processor(event, exc_info)
18341834
if new_event is None:
@@ -1858,7 +1858,7 @@ def run_event_processors(self, event: "Event", hint: "Hint") -> "Optional[Event]
18581858
)
18591859

18601860
for event_processor in event_processors:
1861-
new_event = None
1861+
new_event = event
18621862
with capture_internal_exceptions():
18631863
new_event = event_processor(event, hint)
18641864
if new_event is None:

‎tests/test_basics.py‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -768,49 +768,6 @@ def foo(event, hint):
768768
sentry_sdk.scope.global_event_processors = old_processors
769769

770770

771-
@pytest.mark.tests_internal_exceptions
772-
def test_event_processor_exception_drops_event_and_records_client_report(
773-
sentry_init, capture_events, capture_record_lost_event_calls
774-
):
775-
sentry_init(default_integrations=False)
776-
events = capture_events()
777-
record_lost_event_calls = capture_record_lost_event_calls()
778-
779-
scope = sentry_sdk.get_isolation_scope()
780-
781-
@scope.add_event_processor
782-
def bad_processor(event, hint):
783-
raise ValueError("processor error")
784-
785-
capture_message("should be dropped")
786-
787-
assert len(events) == 0
788-
assert ("event_processor", "error", None, 1) in record_lost_event_calls
789-
790-
791-
@pytest.mark.tests_internal_exceptions
792-
def test_error_processor_exception_drops_event(
793-
sentry_init, capture_events, capture_record_lost_event_calls
794-
):
795-
sentry_init(default_integrations=False)
796-
events = capture_events()
797-
record_lost_event_calls = capture_record_lost_event_calls()
798-
799-
scope = sentry_sdk.get_isolation_scope()
800-
801-
@scope.add_error_processor
802-
def bad_error_processor(event, exc_info):
803-
raise ValueError("error processor error")
804-
805-
try:
806-
raise ValueError("original error")
807-
except Exception:
808-
capture_exception()
809-
810-
assert len(events) == 0
811-
assert ("event_processor", "error", None, 1) in record_lost_event_calls
812-
813-
814771
@pytest.mark.tests_internal_exceptions
815772
def test_before_send_exception_records_callback_error(
816773
sentry_init, capture_events, capture_record_lost_event_calls

0 commit comments

Comments
 (0)