File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
tests/relay_integration/lang/javascript Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -1173,10 +1173,14 @@ def fetch_by_url(self, url):
11731173 cache_key = f"source:cache:v4:{ md5_text (url ).hexdigest ()} "
11741174
11751175 if result is None :
1176- if not self . allow_scraping or not url .startswith (("http:" , "https:" )):
1176+ if not url .startswith (("http:" , "https:" )):
11771177 error = {"type" : EventError .JS_MISSING_SOURCE , "url" : http .expose_url (url )}
11781178 raise http .CannotFetch (error )
11791179
1180+ if not self .allow_scraping :
1181+ error = {"type" : EventError .JS_SCRAPING_DISABLED , "url" : http .expose_url (url )}
1182+ raise http .CannotFetch (error )
1183+
11801184 logger .debug ("Checking cache for url %r" , url )
11811185 result = cache .get (cache_key )
11821186 if result is not None :
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ class EventError:
3535 JS_TOO_LARGE = "js_too_large" # deprecated in favor of FETCH_TOO_LARGE
3636 JS_FETCH_TIMEOUT = "js_fetch_timeout" # deprecated in favor of FETCH_TIMEOUT
3737 JS_MISSING_SOURCES_CONTENT = "js_missing_sources_content"
38+ JS_SCRAPING_DISABLED = "js_scraping_disabled"
3839
3940 # Processing: Native
4041 NATIVE_NO_CRASHED_THREAD = "native_no_crashed_thread"
Original file line number Diff line number Diff line change @@ -1631,6 +1631,42 @@ def test_html_file_with_query_param_ending_with_js_extension(self):
16311631
16321632 assert "errors" not in event .data
16331633
1634+ def test_expansion_with_allow_scraping_false (self ):
1635+ project = self .project
1636+ project .organization .update_option ("sentry:scrape_javascript" , False )
1637+
1638+ data = {
1639+ "timestamp" : self .min_ago ,
1640+ "message" : "hello" ,
1641+ "platform" : "javascript" ,
1642+ "release" : "1.0" ,
1643+ "exception" : {
1644+ "values" : [
1645+ {
1646+ "type" : "Error" ,
1647+ "stacktrace" : {
1648+ "frames" : [
1649+ {
1650+ "abs_path" : "http://example.com/file.min.js" ,
1651+ "filename" : "file.min.js" ,
1652+ "lineno" : 1 ,
1653+ "colno" : 39 ,
1654+ },
1655+ ]
1656+ },
1657+ }
1658+ ]
1659+ },
1660+ }
1661+
1662+ event = self .post_and_retrieve_event (data )
1663+
1664+ assert len (event .data ["errors" ]) == 1
1665+ assert event .data ["errors" ][0 ] == {
1666+ "type" : "js_scraping_disabled" ,
1667+ "url" : "http://example.com/file.min.js" ,
1668+ }
1669+
16341670 def test_expansion_with_debug_id (self ):
16351671 project = self .project
16361672 release = Release .objects .create (organization_id = project .organization_id , version = "abc" )
You can’t perform that action at this time.
0 commit comments