@@ -709,7 +709,7 @@ def inner(obj):
709
709
del meta [str (i )]
710
710
return list_rv , (meta or None )
711
711
if isinstance (obj , AnnotatedValue ):
712
- return obj .value , {"" : obj .metadata }
712
+ return ( inner ( obj .value )[ 0 ] , {"" : obj .metadata })
713
713
return obj , None
714
714
715
715
obj , meta = inner (obj )
@@ -727,6 +727,7 @@ def strip_event_mut(event):
727
727
strip_stacktrace_mut (exception .get ("stacktrace" , None ))
728
728
729
729
strip_request_mut (event .get ("request" , None ))
730
+ strip_breadcrumbs_mut (event .get ("breadcrumbs" , None ))
730
731
731
732
732
733
def strip_stacktrace_mut (stacktrace ):
@@ -747,6 +748,14 @@ def strip_request_mut(request):
747
748
request ["data" ] = strip_databag (data )
748
749
749
750
751
+ def strip_breadcrumbs_mut (breadcrumbs ):
752
+ if not breadcrumbs :
753
+ return
754
+
755
+ for i in range (len (breadcrumbs )):
756
+ breadcrumbs [i ] = strip_databag (breadcrumbs [i ])
757
+
758
+
750
759
def strip_frame_mut (frame ):
751
760
# type: (Dict[str, Any]) -> None
752
761
if "vars" in frame :
@@ -769,32 +778,56 @@ def unmemoize(self, obj):
769
778
770
779
def convert_types (obj ):
771
780
# type: (Any) -> Any
781
+ if obj is None :
782
+ return None
772
783
if obj is CYCLE_MARKER :
773
784
return u"<cyclic>"
774
785
if isinstance (obj , datetime ):
775
- return obj .strftime ("%Y-%m-%dT%H:%M:%SZ" )
786
+ return text_type ( obj .strftime ("%Y-%m-%dT%H:%M:%SZ" ) )
776
787
if isinstance (obj , Mapping ):
777
788
return {k : convert_types (v ) for k , v in obj .items ()}
778
789
if isinstance (obj , Sequence ) and not isinstance (obj , (text_type , bytes )):
779
790
return [convert_types (v ) for v in obj ]
791
+ if isinstance (obj , AnnotatedValue ):
792
+ return AnnotatedValue (convert_types (obj .value ), obj .metadata )
793
+
780
794
if not isinstance (obj , string_types + number_types ):
781
795
return safe_repr (obj )
782
796
if isinstance (obj , bytes ):
783
797
return obj .decode ("utf-8" , "replace" )
798
+
784
799
return obj
785
800
786
801
787
- def strip_databag (obj , remaining_depth = 20 ):
788
- # type: (Any, int) -> Any
802
+ def strip_databag (obj , remaining_depth = 20 , max_breadth = 20 ):
803
+ # type: (Any, int, int ) -> Any
789
804
assert not isinstance (obj , bytes ), "bytes should have been normalized before"
790
805
if remaining_depth <= 0 :
791
806
return AnnotatedValue (None , {"rem" : [["!limit" , "x" ]]})
792
807
if isinstance (obj , text_type ):
793
808
return strip_string (obj )
794
809
if isinstance (obj , Mapping ):
795
- return {k : strip_databag (v , remaining_depth - 1 ) for k , v in obj .items ()}
810
+ rv_dict = {} # type: Dict[Any, Any]
811
+ for i , (k , v ) in enumerate (obj .items ()):
812
+ if i >= max_breadth :
813
+ return AnnotatedValue (rv_dict , {"len" : max_breadth })
814
+ rv_dict [k ] = strip_databag (
815
+ v , remaining_depth = remaining_depth - 1 , max_breadth = max_breadth
816
+ )
817
+
818
+ return rv_dict
796
819
if isinstance (obj , Sequence ):
797
- return [strip_databag (v , remaining_depth - 1 ) for v in obj ]
820
+ rv_list = [] # type: List[Any]
821
+ for i , v in enumerate (obj ):
822
+ if i >= max_breadth :
823
+ return AnnotatedValue (rv_list , {"len" : max_breadth })
824
+ rv_list .append (
825
+ strip_databag (
826
+ v , remaining_depth = remaining_depth - 1 , max_breadth = max_breadth
827
+ )
828
+ )
829
+
830
+ return rv_list
798
831
return obj
799
832
800
833
0 commit comments