|
5 | 5 | import urllib3 # type: ignore |
6 | 6 | import certifi |
7 | 7 | import gzip |
| 8 | +import re |
8 | 9 |
|
9 | 10 | from datetime import datetime, timedelta |
10 | 11 |
|
@@ -93,6 +94,55 @@ def __init__(self, options): |
93 | 94 |
|
94 | 95 | def _send_event(self, event): |
95 | 96 | # type: (Dict[str, Any]) -> None |
| 97 | + |
| 98 | + error_context_lines = [] |
| 99 | + |
| 100 | + # T7565: Collect error message information and skip if any of those |
| 101 | + # messages correspond to messages in our blacklist. Re-implementation |
| 102 | + # of custom code from the deprecated Raven library. |
| 103 | + try: |
| 104 | + exception = event['exception'] |
| 105 | + exc_vals = exception['values'] |
| 106 | + |
| 107 | + for exc_val in exc_vals: |
| 108 | + frames = exc_val['stacktrace']['frames'] |
| 109 | + |
| 110 | + for frame in frames: |
| 111 | + error_context_lines.append(frame['context_line']) |
| 112 | + except (IndexError, KeyError): |
| 113 | + # The event structure is missing some data, so do nothing. |
| 114 | + pass |
| 115 | + else: |
| 116 | + messages_to_ignore = [ |
| 117 | + u"KeyError: 'partial_pipeline'", |
| 118 | + u"TypeError: argument of type 'NoneType' is not iterable", |
| 119 | + u"NotFound: Invalid resource lookup data provided (mismatched" |
| 120 | + " type)", |
| 121 | + u"Invalid resource lookup data provided (mismatched type)", |
| 122 | + u"Forbidden (CSRF token missing or incorrect.)" |
| 123 | + ] |
| 124 | + regex_messages = [ |
| 125 | + r"PdfReadWarning.*", r"Superfluous whitespace.*", |
| 126 | + r"SNIMissingWarning: An HTTPS request has.*", |
| 127 | + r"An HTTPS request has.*", |
| 128 | + r"InsecurePlatformWarning: A true SSLContext.*", |
| 129 | + r"A true SSLContext is not available.*", |
| 130 | + r"RuntimeWarning: DateTimeField.*", |
| 131 | + r"DateTimeField.*received a naive datetime.*", |
| 132 | + r"DeprecationWarning: integer argument expected.*" |
| 133 | + r"integer argument expected, got float.*" |
| 134 | + ] |
| 135 | + |
| 136 | + for context_line in error_context_lines: |
| 137 | + for msg in messages_to_ignore: |
| 138 | + if msg.lower() in context_line.lower() or \ |
| 139 | + context_line.lower() in msg.lower(): |
| 140 | + return |
| 141 | + |
| 142 | + for re_msg in regex_messages: |
| 143 | + if re.match(re_msg, context_line): |
| 144 | + return |
| 145 | + |
96 | 146 | if self._disabled_until is not None: |
97 | 147 | if datetime.utcnow() < self._disabled_until: |
98 | 148 | return |
|
0 commit comments