@@ -452,3 +452,77 @@ def test_strip_event_without_frames_returns_empty_dict(store_and_strip_event) ->
452
452
stripped_event_data = store_and_strip_event (data = event_data )
453
453
454
454
assert stripped_event_data == {}
455
+
456
+
457
+ @django_db_all
458
+ @pytest .mark .snuba
459
+ def test_strip_event_with_multiple_exceptions_only_keep_last_one (store_and_strip_event ) -> None :
460
+ event_data = get_crash_event ()
461
+
462
+ exception_values = list (get_path (event_data , "exception" , "values" ))
463
+
464
+ crash_exception = dict (exception_values [0 ])
465
+ set_path (crash_exception , "type" , value = "SIGPIPE" )
466
+ set_path (crash_exception , "value" , value = "Broken pipe" )
467
+
468
+ exception_values .append (crash_exception )
469
+
470
+ set_path (event_data , "exception" , "values" , value = exception_values )
471
+
472
+ stripped_event_data = store_and_strip_event (data = event_data )
473
+
474
+ assert len (get_path (stripped_event_data , "exception" , "values" )) == 1
475
+
476
+ exception = get_path (stripped_event_data , "exception" , "values" , 0 )
477
+ assert exception ["type" ] == "SIGPIPE"
478
+ assert "value" not in exception
479
+
480
+
481
+ @django_db_all
482
+ @pytest .mark .snuba
483
+ def test_strip_event_with_multiple_exceptions_last_without_frames_discard_event (
484
+ store_and_strip_event ,
485
+ ) -> None :
486
+ event_data = get_crash_event ()
487
+
488
+ exception_values = list (get_path (event_data , "exception" , "values" ))
489
+
490
+ crash_exception = dict (exception_values [0 ])
491
+ set_path (crash_exception , "type" , value = "SIGPIPE" )
492
+ set_path (crash_exception , "value" , value = "Broken pipe" )
493
+ set_path (crash_exception , "stacktrace" , value = None )
494
+ exception_values .append (crash_exception )
495
+
496
+ set_path (event_data , "exception" , "values" , value = exception_values )
497
+
498
+ stripped_event_data = store_and_strip_event (data = event_data )
499
+
500
+ assert stripped_event_data == {}
501
+
502
+
503
+ @django_db_all
504
+ @pytest .mark .snuba
505
+ def test_strip_event_with_multiple_exceptions_first_without_frames_keeps_last_exception (
506
+ store_and_strip_event ,
507
+ ) -> None :
508
+ event_data = get_crash_event ()
509
+
510
+ exception_values = list (get_path (event_data , "exception" , "values" ))
511
+
512
+ crash_exception = dict (exception_values [0 ])
513
+ set_path (crash_exception , "type" , value = "SIGPIPE" )
514
+ set_path (crash_exception , "value" , value = "Broken pipe" )
515
+ exception_values .append (crash_exception )
516
+
517
+ # Remove the stacktrace from the first exception.
518
+ exception_values [0 ]["stacktrace" ] = None
519
+
520
+ set_path (event_data , "exception" , "values" , value = exception_values )
521
+
522
+ stripped_event_data = store_and_strip_event (data = event_data )
523
+
524
+ assert len (get_path (stripped_event_data , "exception" , "values" )) == 1
525
+
526
+ exception = get_path (stripped_event_data , "exception" , "values" , 0 )
527
+ assert exception ["type" ] == "SIGPIPE"
528
+ assert "value" not in exception
0 commit comments