def test_skip_none_values(self): expected = {"exception": {"values": [None, {}]}} actual = deepcopy(expected) assert not rewrite_exception(actual) assert actual == expected
def test_react_error_mapping_resolving(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r''' { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes.", "109": "%s.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.", "110": "Stateless function components cannot have refs." } ''', content_type='application/json' ) for x in range(3): data = { 'platform': 'javascript', 'sentry.interfaces.Exception': { 'values': [ { 'type': 'InvariantViolation', 'value': ( 'Minified React error #109; visit http://facebook' '.github.io/react/docs/error-decoder.html?invariant=' '109&args[]=Component for the full message or use ' 'the non-minified dev environment for full errors ' 'and additional helpful warnings.' ), 'stacktrace': { 'frames': [ { 'abs_path': 'http://example.com/foo.js', 'filename': 'foo.js', 'lineno': 4, 'colno': 0, }, { 'abs_path': 'http://example.com/foo.js', 'filename': 'foo.js', 'lineno': 1, 'colno': 0, }, ], }, } ], } } assert rewrite_exception(data) assert data['sentry.interfaces.Exception']['values'][0]['value'] == ( 'Component.render(): A valid React element (or null) must be ' 'returned. You may have returned undefined, an array or ' 'some other invalid object.' )
def test_react_error_mapping_resolving(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r""" { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes.", "109": "%s.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.", "110": "Stateless function components cannot have refs." } """, content_type="application/json", ) for x in range(3): data = { "platform": "javascript", "exception": { "values": [ { "type": "InvariantViolation", "value": ( "Minified React error #109; visit http://facebook" ".github.io/react/docs/error-decoder.html?invariant=" "109&args[]=Component for the full message or use " "the non-minified dev environment for full errors " "and additional helpful warnings." ), "stacktrace": { "frames": [ { "abs_path": "http://example.com/foo.js", "filename": "foo.js", "lineno": 4, "colno": 0, }, { "abs_path": "http://example.com/foo.js", "filename": "foo.js", "lineno": 1, "colno": 0, }, ] }, } ] }, } assert rewrite_exception(data) assert data["exception"]["values"][0]["value"] == ( "Component.render(): A valid React element (or null) must be " "returned. You may have returned undefined, an array or " "some other invalid object." )
def test_skip_none_values(self): expected = { 'exception': { 'values': [ None, {}, ] } } actual = deepcopy(expected) assert not rewrite_exception(actual) assert actual == expected
def test_react_error_mapping_empty_args(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r''' { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes." } ''', content_type='application/json' ) data = { 'platform': 'javascript', 'sentry.interfaces.Exception': { 'values': [ { 'type': 'InvariantViolation', 'value': ( 'Minified React error #108; visit http://facebook' '.github.io/react/docs/error-decoder.html?invariant=' '108&args[]=Component&args[]= for the full message ' 'or use the non-minified dev environment for full ' 'errors and additional helpful warnings.' ), 'stacktrace': { 'frames': [ { 'abs_path': 'http://example.com/foo.js', 'filename': 'foo.js', 'lineno': 4, 'colno': 0, }, ], }, } ], } } assert rewrite_exception(data) assert data['sentry.interfaces.Exception']['values'][0]['value'] == ( 'Component.getChildContext(): key "" is not defined in ' 'childContextTypes.' )
def test_react_error_mapping_empty_args(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r""" { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes." } """, content_type="application/json", ) data = { "platform": "javascript", "exception": { "values": [ { "type": "InvariantViolation", "value": ( "Minified React error #108; visit http://facebook" ".github.io/react/docs/error-decoder.html?invariant=" "108&args[]=Component&args[]= for the full message " "or use the non-minified dev environment for full " "errors and additional helpful warnings." ), "stacktrace": { "frames": [ { "abs_path": "http://example.com/foo.js", "filename": "foo.js", "lineno": 4, "colno": 0, } ] }, } ] }, } assert rewrite_exception(data) assert data["exception"]["values"][0]["value"] == ( 'Component.getChildContext(): key "" is not defined in ' "childContextTypes." )
def test_react_error_mapping_truncated(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r''' { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes." } ''', content_type='application/json' ) data = { 'platform': 'javascript', 'sentry.interfaces.Exception': { 'values': [ { 'type': 'InvariantViolation', 'value': ( u'Minified React error #108; visit http://facebook' u'.github.io/react/docs/error-decoder.html?…' ), 'stacktrace': { 'frames': [ { 'abs_path': 'http://example.com/foo.js', 'filename': 'foo.js', 'lineno': 4, 'colno': 0, }, ], }, } ], } } assert rewrite_exception(data) assert data['sentry.interfaces.Exception']['values'][0]['value'] == ( '<redacted>.getChildContext(): key "<redacted>" is not defined in ' 'childContextTypes.' )
def test_react_error_mapping_truncated(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r''' { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes." } ''', content_type='application/json' ) data = { 'platform': 'javascript', 'sentry.interfaces.Exception': { 'values': [ { 'type': 'InvariantViolation', 'value': ( u'Minified React error #108; visit http://facebook' u'.github.io/react/docs/error-decoder.html?\u2026' ), 'stacktrace': { 'frames': [ { 'abs_path': 'http://example.com/foo.js', 'filename': 'foo.js', 'lineno': 4, 'colno': 0, }, ], }, } ], } } assert rewrite_exception(data) assert data['sentry.interfaces.Exception']['values'][0]['value'] == ( '<redacted>.getChildContext(): key "<redacted>" is not defined in ' 'childContextTypes.' )
def test_react_error_mapping_truncated(self): responses.add( responses.GET, REACT_MAPPING_URL, body=r""" { "108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes." } """, content_type="application/json", ) data = { "platform": "javascript", "exception": { "values": [ { "type": "InvariantViolation", "value": ( "Minified React error #108; visit http://facebook" ".github.io/react/docs/error-decoder.html?\u2026" ), "stacktrace": { "frames": [ { "abs_path": "http://example.com/foo.js", "filename": "foo.js", "lineno": 4, "colno": 0, } ] }, } ] }, } assert rewrite_exception(data) assert data["exception"]["values"][0]["value"] == ( '<redacted>.getChildContext(): key "<redacted>" is not defined in ' "childContextTypes." )