internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: getsentry/sentry

Issue:
BrowserExtensionsFilter: _gCrWeb autofill error in iOS Chrome not ignored
This seems to be a relatively well-known issue on Chrome for iOS. It seems this could be ignored safely by the filter as well.

Source: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/7VU0_VvC7mE


Discussion:

Resolving patch:
diff --git a/src/sentry/filters/browser_extensions.py b/src/sentry/filters/browser_extensions.py
--- a/src/sentry/filters/browser_extensions.py
+++ b/src/sentry/filters/browser_extensions.py
@@ -24,6 +24,8 @@
     # See http://stackoverflow.com/questions/4113268
     'bmi_SafeAddOnload',
     'EBCallBackMessageReceived',
+    # See https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/7VU0_VvC7mE
+    '_gCrWeb',
     # See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
     'conduitPage'
 ))), re.I)


Test patch:
Repository: getsentry/sentry

Issue:
Crash Reports Corrupt When System Symbols are Missing
Currently it appears to be the case that when system symbols are missing on iOS frames are entirely removed from the output.


Discussion:
Hi,
This also applies to macOS, and seem to have started ~2-4 weeks ago. 

Resolving patch:
diff --git a/src/sentry/lang/native/symbolizer.py b/src/sentry/lang/native/symbolizer.py
--- a/src/sentry/lang/native/symbolizer.py
+++ b/src/sentry/lang/native/symbolizer.py
@@ -249,8 +249,9 @@ def symbolize_backtrace(self, backtrace, sdk_info=None):
 
         for idx, frm in enumerate(backtrace):
             try:
-                rv.append(self.symbolize_frame(frm, sdk_info) or frm)
+                rv.append(self.symbolize_frame(frm, sdk_info))
             except SymbolicationFailed as e:
+                rv.append(frm)
                 errors.append({
                     'type': EventError.NATIVE_INTERNAL_FAILURE,
                     'frame': frm,


Test patch:
Repository: getsentry/sentry

Issue:
extend auto-resolve timeframe to be more than 7 days (up to 90 days will be nice)



Discussion:
As I understand it, 90 days is lifespan of the data, so issues unseen for 90 days are implicitly resolved/delete?

30 days would be my ideal.


Resolving patch:
diff --git a/src/sentry/web/frontend/project_settings.py b/src/sentry/web/frontend/project_settings.py
--- a/src/sentry/web/frontend/project_settings.py
+++ b/src/sentry/web/frontend/project_settings.py
@@ -50,7 +50,7 @@ class EditProjectForm(forms.ModelForm):
         required=False,
     )
     resolve_age = RangeField(label=_('Auto resolve'), required=False,
-        min_value=0, max_value=168, step_value=1,
+        min_value=0, max_value=720, step_value=1,
         help_text=_('Automatically resolve an issue if it hasn\'t been seen for this amount of time.'))
     scrub_data = forms.BooleanField(
         label=_('Data Scrubber'),


Test patch:
Repository: getsentry/sentry

Issue:
Webhook data does not have event id
Webhook data contains issue id only. It would be nice to have event id as well.

Discussed with @mattrobenolt on IRC. Documenting it here with this issue.


Discussion:
I am working on this 

Resolving patch:
diff --git a/src/sentry/plugins/sentry_webhooks/plugin.py b/src/sentry/plugins/sentry_webhooks/plugin.py
--- a/src/sentry/plugins/sentry_webhooks/plugin.py
+++ b/src/sentry/plugins/sentry_webhooks/plugin.py
@@ -87,6 +87,8 @@ def get_group_data(self, group, event):
         }
         data['event'] = dict(event.data or {})
         data['event']['tags'] = event.get_tags()
+        data['event']['event_id'] = event.event_id
+        data['event']['id'] = event.id
         return data
 
     def get_webhook_urls(self, project):


Test patch:
diff --git a/tests/sentry/plugins/sentry_webhooks/test_plugin.py b/tests/sentry/plugins/sentry_webhooks/test_plugin.py
--- a/tests/sentry/plugins/sentry_webhooks/test_plugin.py
+++ b/tests/sentry/plugins/sentry_webhooks/test_plugin.py
@@ -23,7 +23,7 @@ def test_simple_notification(self):
         responses.add(responses.POST, 'http://example.com')
 
         group = self.create_group(message='Hello world')
-        event = self.create_event(group=group, message='Hello world', tags={'level': 'warning'})
+        event = self.create_event(group=group, message='Hello world', tags={'level': 'warning'}, id=24)
 
         rule = Rule.objects.create(project=self.project, label='my rule')
 
@@ -39,3 +39,5 @@ def test_simple_notification(self):
 
         assert payload['level'] == 'warning'
         assert payload['message'] == 'Hello world'
+        assert payload['event']['id'] == 24
+        assert payload['event']['event_id'] == event.event_id
Repository: getsentry/sentry

Issue:
MYSQL_PWD not recognized as sensitive field
In Sentry 8.11.0, the data key `MYSQL_PWD` is not treated as sensitive and is transmitted in cleartext and shown in the UI, while things that look like mysql connection string are rendered as `mysql://readonly:[Filtered]@db1.example.com/`

MYSQL_PWD is the standard way of providing a password to mysql cli tools, and I'd argue any field that ends in _PWD is unsafe.


Discussion:

Resolving patch:
diff --git a/src/sentry/constants.py b/src/sentry/constants.py
--- a/src/sentry/constants.py
+++ b/src/sentry/constants.py
@@ -173,6 +173,7 @@ def get_all_languages():
     'access_token',
     'auth',
     'credentials',
+    'mysql_pwd',
 )
 
 VALID_PLATFORMS = set([


Test patch:
diff --git a/tests/sentry/utils/test_data_scrubber.py b/tests/sentry/utils/test_data_scrubber.py
--- a/tests/sentry/utils/test_data_scrubber.py
+++ b/tests/sentry/utils/test_data_scrubber.py
@@ -366,3 +366,8 @@ def test_empty_field(self):
         proc = SensitiveDataFilter(fields=[''])
         proc.apply(data)
         assert data['extra'] == {'foobar': 'xxx'}
+
+    def test_should_have_mysql_pwd_as_a_default(self):
+        proc = SensitiveDataFilter(include_defaults=True)
+        assert proc.sanitize('MYSQL_PWD', 'the one') == FILTER_MASK
+        assert proc.sanitize('mysql_pwd', 'the two') == FILTER_MASK
Repository: getsentry/sentry

Issue:
Localhost filter should consider affected URL
Right now the "localhost" filter only consider's the affected User's IP: https://github.com/getsentry/sentry/blob/master/src/sentry/filters/localhost.py

But users are also expecting that this should filter server errors triggered from a server running on localhost (e.g. local development).

See also: #4729, #4762


Discussion:

Resolving patch:
diff --git a/src/sentry/filters/localhost.py b/src/sentry/filters/localhost.py
--- a/src/sentry/filters/localhost.py
+++ b/src/sentry/filters/localhost.py
@@ -1,8 +1,10 @@
 from __future__ import absolute_import
 
 from .base import Filter
+from six.moves.urllib.parse import urlparse
 
 LOCAL_IPS = frozenset(['127.0.0.1', '::1'])
+LOCAL_DOMAINS = frozenset(['127.0.0.1', 'localhost'])
 
 
 class LocalhostFilter(Filter):
@@ -16,5 +18,14 @@ def get_ip_address(self, data):
         except KeyError:
             return ''
 
+    def get_url(self, data):
+        try:
+            return data['sentry.interfaces.Http']['url'] or ''
+        except KeyError:
+            return ''
+
+    def get_domain(self, data):
+        return urlparse(self.get_url(data)).netloc
+
     def test(self, data):
-        return self.get_ip_address(data) in LOCAL_IPS
+        return self.get_ip_address(data) in LOCAL_IPS or self.get_domain(data) in LOCAL_DOMAINS


Test patch:
diff --git a/tests/sentry/filters/test_localhost.py b/tests/sentry/filters/test_localhost.py
--- a/tests/sentry/filters/test_localhost.py
+++ b/tests/sentry/filters/test_localhost.py
@@ -10,10 +10,13 @@ class LocalhostFilterTest(TestCase):
     def apply_filter(self, data):
         return self.filter_cls(self.project).test(data)
 
-    def get_mock_data(self, client_ip=None):
+    def get_mock_data(self, client_ip=None, url=None):
         return {
             'sentry.interfaces.User': {
                 'ip_address': client_ip,
+            },
+            'sentry.interfaces.Http': {
+                'url': url,
             }
         }
 
@@ -31,3 +34,20 @@ def test_does_not_filter_external_ip(self):
 
     def test_fails_gracefully_without_user(self):
         assert not self.apply_filter({})
+
+    def test_filters_localhost_domain(self):
+        data = self.get_mock_data(url='http://localhost/something.html')
+        assert self.apply_filter(data)
+
+        data = self.get_mock_data(url='https://localhost')
+        assert self.apply_filter(data)
+
+        data = self.get_mock_data(url='https://127.0.0.1')
+        assert self.apply_filter(data)
+
+    def test_does_not_filter_non_localhost_domain(self):
+        data = self.get_mock_data(url='https://getsentry.com/')
+        assert not self.apply_filter(data)
+
+        data = self.get_mock_data(url='http://example.com/index.html?domain=localhost')
+        assert not self.apply_filter(data)
Repository: getsentry/sentry

Issue:
After upgrading to 8.21, Sentry upgrade wizard hangs on auth.allow-registration
When upgrading my onpremise installation form 8.20 to 8.21 (using docker-compose), the wizard prompted me to set the “Anonymize Beacon” option. When clicking “Continue”, the following error message pops up:
> An invalid value for (auth.allow-registration) was passed to the server.

There was no such option `auth.allow-registration` set in either `sentry.conf.py` or `config.yml`.

The call to `https://sentry.example.com/api/0/internal/options/` returned a 400, with the following params:
```
system.admin-email: admin@example.com
system.url-prefix | https://sentry.example.com
auth.allow-registration | 0
beacon.anonymous | true
```
I worked around that by resending the request, changing 0 for False. My install is now fine

Running `sentry config get auth.allow-registration`, whether before the fix or after, returns:
```
        type: BOOLEAN
 from config: <not set>
     current: 0
```
This looks somehow similar to #5699.

Hope that helps!


Discussion:

Resolving patch:
diff --git a/src/sentry/utils/types.py b/src/sentry/utils/types.py
--- a/src/sentry/utils/types.py
+++ b/src/sentry/utils/types.py
@@ -70,8 +70,11 @@ class BoolType(Type):
     name = 'boolean'
     default = False
     expected_types = (bool, )
+    compatible_types = six.string_types + six.integer_types
 
     def convert(self, value):
+        if isinstance(value, six.integer_types):
+            return bool(value)
         value = value.lower()
         if value in ('y', 'yes', 't', 'true', '1', 'on'):
             return True


Test patch:
diff --git a/tests/sentry/api/endpoints/test_system_options.py b/tests/sentry/api/endpoints/test_system_options.py
--- a/tests/sentry/api/endpoints/test_system_options.py
+++ b/tests/sentry/api/endpoints/test_system_options.py
@@ -51,6 +51,13 @@ def test_disabled_smtp(self):
             assert response.data['mail.host']['field']['disabled'] is True
             assert response.data['mail.host']['field']['disabledReason'] == 'smtpDisabled'
 
+    def test_put_int_for_boolean(self):
+        self.login_as(user=self.user)
+        response = self.client.put(self.url, {
+            'auth.allow-registration': 1,
+        })
+        assert response.status_code == 200
+
     def test_put_unknown_option(self):
         self.login_as(user=self.user)
         response = self.client.put(self.url, {
diff --git a/tests/sentry/utils/test_types.py b/tests/sentry/utils/test_types.py
--- a/tests/sentry/utils/test_types.py
+++ b/tests/sentry/utils/test_types.py
@@ -27,6 +27,7 @@ def test_any(self):
 
     def test_bool(self):
         assert Bool(True) is True
+        assert Bool(1) is True
         assert Bool('y') is True
         assert Bool('YES') is True
         assert Bool('t') is True
@@ -34,6 +35,7 @@ def test_bool(self):
         assert Bool('1') is True
         assert Bool('on') is True
         assert Bool(False) is False
+        assert Bool(0) is False
         assert Bool('n') is False
         assert Bool('NO') is False
         assert Bool('f') is False
Repository: getsentry/sentry

Issue:
Unable to disable "Claim unassigned issues when resolving them"
At this page https://sentry.io/account/settings/notifications/ I have the "Claim unassigned issues when resolving them" checkbox enabled.

If I disable this and click "Save Changes", it appears to save – it shows "Your settings were saved" – and some settings *are* saved, but not this checkbox.

This doesn't seem to be a display issue; if I resolve an issue, I am still assigned to it, even after "changing" the setting.

Using Firefox 57 on Linux.


Discussion:

Resolving patch:
diff --git a/src/sentry/web/forms/accounts.py b/src/sentry/web/forms/accounts.py
--- a/src/sentry/web/forms/accounts.py
+++ b/src/sentry/web/forms/accounts.py
@@ -690,6 +690,12 @@ def save(self):
             value='1' if self.cleaned_data['self_notifications'] else '0',
         )
 
+        UserOption.objects.set_value(
+            user=self.user,
+            key='self_assign_issue',
+            value='1' if self.cleaned_data['self_assign_issue'] else '0',
+        )
+
         workflow_notifications_value = self.cleaned_data.get('workflow_notifications')
         if not workflow_notifications_value:
             UserOption.objects.unset_value(


Test patch:
Repository: getsentry/sentry

Issue:
build: Fix eslint results in travis logs
eslint currently outputs XML for zeus to ingest, but prints the XML to console as well. Ideally we would have checkstyle formatter write to XML file but standard formatter write to stdout

Reference: https://github.com/eslint/eslint/issues/8185


Discussion:

Resolving patch:
diff --git a/src/sentry/lint/engine.py b/src/sentry/lint/engine.py
--- a/src/sentry/lint/engine.py
+++ b/src/sentry/lint/engine.py
@@ -39,6 +39,10 @@ def get_project_root():
     return os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)
 
 
+def get_sentry_bin(name):
+    return os.path.join(get_project_root(), 'bin', name)
+
+
 def get_node_modules_bin(name):
     return os.path.join(
         get_project_root(), 'node_modules', '.bin', name)
@@ -121,7 +125,9 @@ def py_lint(file_list, parseable=False):
 
 def js_lint(file_list=None, parseable=False, format=False):
 
+    # We require eslint in path but we actually call an eslint wrapper
     eslint_path = get_node_modules_bin('eslint')
+    eslint_wrapper_path = get_sentry_bin('eslint-travis-wrapper')
 
     if not os.path.exists(eslint_path):
         from click import echo
@@ -132,7 +138,11 @@ def js_lint(file_list=None, parseable=False, format=False):
 
     has_errors = False
     if js_file_list:
-        cmd = [eslint_path, '--ext', '.js,.jsx']
+        if os.environ.get('CI'):
+            cmd = [eslint_wrapper_path, '--ext', '.js,.jsx']
+        else:
+            cmd = [eslint_path, '--ext', '.js,.jsx']
+
         if format:
             cmd.append('--fix')
         if parseable:


Test patch:
Repository: getsentry/sentry

Issue:
Project named "Billing" interferes with billing and usage page
Hi,

I'm using the hosted instance of Sentry.

I have created a new project for the organization called "billing".  I am trying to access the project's settings, but get redirected to `/settings/organization/billing/overview` which is the Usage & Billing page, not the project's settings.

The usage & billing page's url needs to be altered, or "billing" needs to become a reserved word or something so that other people dont run into the same problem as me.

I've reached out to sentry support via mail to rectify my current situation.


Discussion:
Thanks @MaggotMouth, I'll add the `billing` slug (as well as others) to the reserved project name list. I'm assuming you've contacted support to have the project renamed?

Resolving patch:
diff --git a/src/sentry/constants.py b/src/sentry/constants.py
--- a/src/sentry/constants.py
+++ b/src/sentry/constants.py
@@ -93,7 +93,8 @@ def get_all_languages():
 
 RESERVED_PROJECT_SLUGS = frozenset((
     'api-keys', 'audit-log', 'auth', 'members', 'projects',
-    'rate-limits', 'repos', 'settings', 'teams',
+    'rate-limits', 'repos', 'settings', 'teams', 'billing',
+    'payments', 'legal', 'subscription', 'support',
 ))
 
 LOG_LEVELS = {


Test patch:
Repository: getsentry/sentry

Issue:
Assert that --queues argument(s) actually exist in codebase before starting celeryd.
Currently, if someone runs a celery worker with the argument:`--queues no-way-this-queue-actually-exists-yet`  RabbitMQ will create a queue with the default options, which will cause any future production to the queue to error if there is a configuration mismatch.


Discussion:

Resolving patch:
diff --git a/src/sentry/runner/commands/run.py b/src/sentry/runner/commands/run.py
--- a/src/sentry/runner/commands/run.py
+++ b/src/sentry/runner/commands/run.py
@@ -211,10 +211,38 @@ def run_worker(**options):
 @click.option("--without-mingle", is_flag=True, default=False)
 @click.option("--without-heartbeat", is_flag=True, default=False)
 @click.option("--max-tasks-per-child", default=10000)
+@click.option("--ignore-unknown-queues", is_flag=True, default=False)
 @log_options()
 @configuration
-def worker(**options):
+def worker(ignore_unknown_queues, **options):
     """Run background worker instance and autoreload if necessary."""
+
+    from sentry.celery import app
+
+    known_queues = frozenset(c_queue.name for c_queue in app.conf.CELERY_QUEUES)
+
+    if options["queues"] is not None:
+        if not options["queues"].issubset(known_queues):
+            unknown_queues = options["queues"] - known_queues
+            message = "Following queues are not found: %s" % ",".join(sorted(unknown_queues))
+            if ignore_unknown_queues:
+                options["queues"] -= unknown_queues
+                click.echo(message)
+            else:
+                raise click.ClickException(message)
+
+    if options["exclude_queues"] is not None:
+        if not options["exclude_queues"].issubset(known_queues):
+            unknown_queues = options["exclude_queues"] - known_queues
+            message = "Following queues cannot be excluded as they don't exist: %s" % ",".join(
+                sorted(unknown_queues)
+            )
+            if ignore_unknown_queues:
+                options["exclude_queues"] -= unknown_queues
+                click.echo(message)
+            else:
+                raise click.ClickException(message)
+
     if options["autoreload"]:
         from django.utils import autoreload
 


Test patch:
Repository: getsentry/sentry

Issue:
Last Active Organization not set in API
Currently, a user's last active organization is set only in the Django code: https://github.com/getsentry/sentry/blob/master/src/sentry/web/frontend/base.py#L34

This means that last active organization is not set when a user navigates to a view via a front-end route.

As more of Sentry's views are converted to React, we will lose accurate functionality around a user's last active organization.



Discussion:

Resolving patch:
diff --git a/src/sentry/api/bases/organization.py b/src/sentry/api/bases/organization.py
--- a/src/sentry/api/bases/organization.py
+++ b/src/sentry/api/bases/organization.py
@@ -145,9 +145,13 @@ def convert_args(self, request, organization_slug, *args, **kwargs):
         raven.tags_context({
             'organization': organization.id,
         })
-
         request._request.organization = organization
 
+        # Track the 'active' organization when the request came from
+        # a cookie based agent (react app)
+        if request.auth is None and request.user:
+            request.session['activeorg'] = organization.slug
+
         kwargs['organization'] = organization
         return (args, kwargs)
 


Test patch:
diff --git a/tests/sentry/api/endpoints/test_organization_projects.py b/tests/sentry/api/endpoints/test_organization_projects.py
--- a/tests/sentry/api/endpoints/test_organization_projects.py
+++ b/tests/sentry/api/endpoints/test_organization_projects.py
@@ -19,6 +19,7 @@ def test_simple(self):
         assert response.status_code == 200, response.content
         assert len(response.data) == 1
         assert response.data[0]['id'] == six.text_type(project.id)
+        assert self.client.session['activeorg'] == org.slug
 
     def test_with_stats(self):
         self.login_as(user=self.user)
Repository: getsentry/sentry

Issue:
CSP-Report causes Cross-Origin Read Blocking (CORB)
Hi folks,

we are using a Sentry v9.0.0. on premise. As with the newly released Chrome 68 we are facing some minor issue that the response of the CSP-Reports includes the HTTP-Header `Content-Type: text/html`.

```
HTTP/1.1 201 CREATED
Content-Length: 0
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Language: en
Expires: Wed, 08 Aug 2018 15:09:41 GMT
Vary: Accept-Language, Cookie
Last-Modified: Wed, 08 Aug 2018 15:09:41 GMT
Cache-Control: max-age=0
X-Frame-Options: deny
Content-Type: text/html; charset=utf-8
```

See [here](https://www.chromium.org/Home/chromium-security/corb-for-developers) for the announcement of the Chromium team towards CORB.

As we are not evaluating the actually empty response response, this is not a problem at the moment.


Discussion:
What should we actually be returning here then? There is no body at all. I guess omitting Content-Type entirely?
If I understand it correctly there are multiple options.

1. set `Content-Type: application/javascript`
1. remove the `X-Content-Type-Options: nosniff`
1. set `Access-Control-Allow-Origin: *`

It sound like that the first option is the one that makes sense. As long as the body is empty, returning `Content-Type: application/javascript` might be another solution.

Here is a good explanation: https://youtu.be/dBuykrdhK-A?t=23m11s
Here is another video talking about CORB

https://youtu.be/_5rX6pt0A_k

Resolving patch:
diff --git a/src/sentry/web/api.py b/src/sentry/web/api.py
--- a/src/sentry/web/api.py
+++ b/src/sentry/web/api.py
@@ -746,7 +746,7 @@ def post(self, request, project, helper, **kwargs):
         )
         if isinstance(response_or_event_id, HttpResponse):
             return response_or_event_id
-        return HttpResponse(status=201)
+        return HttpResponse(content_type='application/javascript', status=201)
 
     def security_report_type(self, body):
         report_type_for_key = {


Test patch: