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

Issue:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' 
## Important Details

How are you running Sentry?

* [x] On-Premise docker [Version 9.0.0]
* [ ] Saas (sentry.io)
* [ ] Other [briefly describe your environment]

## Description

I've got this exception in the `internal` Sentry project :
`UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128)`

This seems to happen while sending an alert email.

![image](https://user-images.githubusercontent.com/8047492/48716664-1aee5f80-ec18-11e8-8d48-6bd553d791bd.png)

## Steps to Reproduce

1. Send event with an environment tag containing accent (like `développement`)
2. Go to internal project
3. Note the presence of above exception

### What you expected to happen

Be able to receive emails with accents (UTF-8) support.



Discussion:
Sentry issue: [SENTRY-84F](https://sentry.io/sentry/sentry/issues/753386813/?referrer=github_integration)

Resolving patch:
diff --git a/src/sentry/models/group.py b/src/sentry/models/group.py
--- a/src/sentry/models/group.py
+++ b/src/sentry/models/group.py
@@ -16,8 +16,8 @@
 from django.core.urlresolvers import reverse
 from django.db import models
 from django.utils import timezone
+from django.utils.http import urlencode
 from django.utils.translation import ugettext_lazy as _
-from six.moves.urllib.parse import urlencode
 
 from sentry import eventtypes, tagstore
 from sentry.constants import (


Test patch:
diff --git a/tests/sentry/models/test_group.py b/tests/sentry/models/test_group.py
--- a/tests/sentry/models/test_group.py
+++ b/tests/sentry/models/test_group.py
@@ -230,3 +230,12 @@ def test_get_email_subject(self):
         group = self.create_group(project=project)
 
         assert group.get_email_subject() == '%s - %s' % (group.qualified_short_id, group.title)
+
+    def test_get_absolute_url(self):
+        project = self.create_project(name='pumped-quagga')
+        group = self.create_group(project=project)
+
+        result = group.get_absolute_url({'environment': u'd\u00E9v'})
+        assert result == u'http://testserver/baz/{}/issues/{}/?environment=d%C3%A9v'.format(
+            project.slug,
+            group.id)
Repository: getsentry/sentry

Issue:
Google Pubsub push messages mis-identified as crawler
## Important Details

How are you running Sentry?

* [ ] On-Premise docker [Version xyz]
* [x] Saas (sentry.io)
* [ ] Other [briefly describe your environment]

## Description

We get the Sentry API error `Sentry responded with an API error: APIError(Event dropped due to filter: web-crawlers)` when there's an exception in a [Google Pubsub push](https://cloud.google.com/pubsub/docs/push) handler.

Apparently the user agent is `APIs-Google`.

## Steps to Reproduce

1. Set up a Google Pubsub push HTTP event handler
2. Have an exception in the message handler code
3. Not get report in Sentry

### What you expected to happen

`APIs-Google` isn't identified as a web crawler.

### Possible Solution

Improve the regex? 😸 



Discussion:
Ah great, this user agent is actually properly documented by Google, so it's safe to exclude: https://support.google.com/webmasters/answer/7426684?hl=en
Can I get this one?
@ShanTulshi sure! Ping me in the pull request.

Resolving patch:
diff --git a/src/sentry/filters/web_crawlers.py b/src/sentry/filters/web_crawlers.py
--- a/src/sentry/filters/web_crawlers.py
+++ b/src/sentry/filters/web_crawlers.py
@@ -16,8 +16,8 @@
             r'AdsBot',
             # Google Adsense
             r'Mediapartners',
-            # Google+ and Google web search
-            r'Google',
+            # Google+ and Google web search, but not apis-google
+            r'(?<!APIs-)Google',
             # Bing search
             r'BingBot',
             r'BingPreview',


Test patch:
diff --git a/tests/sentry/filters/test_web_crawlers.py b/tests/sentry/filters/test_web_crawlers.py
--- a/tests/sentry/filters/test_web_crawlers.py
+++ b/tests/sentry/filters/test_web_crawlers.py
@@ -1,14 +1,16 @@
 from __future__ import absolute_import
 
+from sentry.models import Project
 from sentry.filters.web_crawlers import WebCrawlersFilter
-from sentry.testutils import TestCase
+from unittest import TestCase
 
 
 class WebCrawlersFilterTest(TestCase):
     filter_cls = WebCrawlersFilter
 
     def apply_filter(self, data):
-        return self.filter_cls(self.project).test(data)
+        project = Project()
+        return self.filter_cls(project).test(data)
 
     def get_mock_data(self, user_agent):
         return {
@@ -50,3 +52,7 @@ def test_filters_calypso_appcrawler(self):
             'Mozilla/5.0 (Linux; Android 6.0.1; Calypso AppCrawler Build/MMB30Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.124 Mobile Safari/537.36'
         )
         assert self.apply_filter(data)
+
+    def test_filters_google_apis(self):
+        data = self.get_mock_data('APIs-Google')
+        assert not self.apply_filter(data)
Repository: getsentry/sentry

Issue:
Switch license to Apache 2
Let's do it.


Discussion:
Need to confirm the recent React concerns won't affect us.
https://github.com/facebook/react/issues/10191
So one concern, and I'm not sure if avoidable, we need to add license headers to files to be correct via Apache.

This IS possible to do, but is not going to be fun. Facebook does it via Phabricator, and we could do it via pre-commit/`calm`.
https://github.com/projectcalico/felix/blob/master/git-hooks/pre-commit

https://github.com/NitorCreations/license-maintainer
Aside once we fully resolve this, let's plan to transition all SDKs and open source work from Sentry to the same structure. I dont THINK there will be any concerns from upsteam users on those, but we will be confirming with legal advisor first, and might offer dual license options.
Just curious, what’s the goal here? You’re using a standard 3-clause BSD license afaict, which is very permissive already and you don’t have the patents addition that Facebook added to react.

The react story thus is unrelated.

As for license headers, that’s not an ASL2 requirement, just ASF policy for its own projects. Were you too witch to ASL2, all you need is copying the license text into your `LICENSE` file.
@janl good to know (re: LICENSE file). My concerns were more around we're not actually declaring who the copyright holder(s) are anywhere given the standard Apache text doesnt include anything.

Our goal is a more universally understood license with potential future protections. Given that Sentry's a growing business, it's possible we may want/need to take advantage of the patents protections Apache offers (down the road), as well as having access to the CLA (though we may never use it). Apache is also the most understand on the legal side, and its something we've more or less standardized on in newer projects for quite a while.

(Aside we had talked about the React bit internally, and that was the same conclusion we came to, as it was just a misunderstanding)
@dcramer that’s all well thought out, keep going :) #asfmemberout
@BYK can we close this?
@EvanPurkhiser we haven't switched the license yet :)

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -136,7 +136,7 @@ def run(self):
     install_requires=install_requires,
     extras_require={"dev": dev_requires, "postgres": []},
     cmdclass=cmdclass,
-    license="BSD",
+    license="BSL-1.1",
     include_package_data=True,
     entry_points={
         "console_scripts": ["sentry = sentry.runner:main"],
@@ -180,5 +180,6 @@ def run(self):
         "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 2 :: Only",
         "Topic :: Software Development",
+        "License :: Other/Proprietary License",
     ],
 )


Test patch:
Repository: getsentry/sentry

Issue:
Simple typo in the compact docstring for utils.functional
## Important Details

How are you running Sentry?

* [ ] On-Premise docker [Version xyz]
* [ ] Saas (sentry.io)
* [x] Other [briefly describe your environment]
Observed documentation - not running sentry.

## Description

Simple typo should be values rather than valules.

## Steps to Reproduce

1. Observe docstring in utils.functional.compact method

### What you expected to happen

Should be values rather than valules.

### Possible Solution

Replace valules with values.



Discussion:

Resolving patch:
diff --git a/src/sentry/utils/functional.py b/src/sentry/utils/functional.py
--- a/src/sentry/utils/functional.py
+++ b/src/sentry/utils/functional.py
@@ -46,7 +46,7 @@ def compact(seq):
         Removes keys with a corresponding ``None`` value.
 
     list:
-        Removes ``None`` valules.
+        Removes ``None`` values.
 
     >>> compact({'foo': 'bar', 'baz': None})
     {'foo': 'bar'}


Test patch:
Repository: getsentry/sentry

Issue:
Unclear instructions for GitLab integration setup
> Step 1: Create a Sentry App in GitLab

> To configure GitLab with Sentry, you will need to create a Sentry app in your GitLab instance.

> You'll also need to be a maintainer or owner in GitLab. Projects owned by users are not supported.

> Navigate to the **User Settings** section of your GitLab instance.

> In the sidebar, select 'Applications'.

Did the author mean `https://gitlaburl/admin`? If so, this is called `Admin Area`:

![image](https://user-images.githubusercontent.com/611746/75067118-f71c6800-54b1-11ea-8c30-4d24449abe9b.png)

Also, providing a direct URL won't hurt. Why not something like this:

> Navigate to the Admin Area of your GitLab instance, then select "Applications" in the sidebar. (Or navigate directly to /admin/applications/new)


Discussion:
> Did the author mean https://gitlaburl/admin? If so, this is called Admin Area:

No I meant the settings for your user account, like those found in https://gitlab.com/profile/applications

Resolving patch:
diff --git a/src/sentry/integrations/gitlab/integration.py b/src/sentry/integrations/gitlab/integration.py
--- a/src/sentry/integrations/gitlab/integration.py
+++ b/src/sentry/integrations/gitlab/integration.py
@@ -175,6 +175,10 @@ def clean_url(self):
 
 class InstallationConfigView(PipelineView):
     def dispatch(self, request, pipeline):
+        if "goback" in request.GET:
+            pipeline.state.step_index = 0
+            return pipeline.current_step()
+
         if request.method == "POST":
             form = InstallationForm(request.POST)
             if form.is_valid():


Test patch:
diff --git a/tests/sentry/integrations/gitlab/test_integration.py b/tests/sentry/integrations/gitlab/test_integration.py
--- a/tests/sentry/integrations/gitlab/test_integration.py
+++ b/tests/sentry/integrations/gitlab/test_integration.py
@@ -137,6 +137,22 @@ def test_basic_flow(self, mock_sha):
         assert identity.status == IdentityStatus.VALID
         assert identity.data == {"access_token": "xxxxx-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx"}
 
+    def test_goback_to_instructions(self):
+        # Go to instructions
+        resp = self.client.get(self.init_path)
+        assert resp.status_code == 200
+        self.assertContains(resp, "Step 1")
+
+        # Go to setup form
+        resp = self.client.get(self.init_path_without_guide)
+        assert resp.status_code == 200
+        self.assertContains(resp, "Step 2")
+
+        # Go to back to instructions
+        resp = self.client.get(self.init_path + '?goback=1')
+        assert resp.status_code == 200
+        self.assertContains(resp, "Step 1")
+
     @responses.activate
     def test_setup_missing_group(self):
         resp = self.client.get(self.init_path_without_guide)
Repository: getsentry/sentry

Issue:
Event migration 9.1.2 -> 10
<!--

Do you want to ask a question? Are you looking for support? The Sentry message
board is the best place for getting support: https://forum.sentry.io
-->

## Important Details

How are you running Sentry?

* [X] On-Premise docker [Version 9.1.2]
* [ ] Saas (sentry.io)
* [ ] Other [briefly describe your environment]

## Description

I followed the migration guide, alongside all fixes and workaround and managed to get to the actual migration routine. Sentry tries to process all existing postgres events but fails to (for every event):

```
An error occured while trying to instert the following event: <sentry.eventstore.models.Event object at 0x7f2f08e552d0>
.----
insert() takes at least 8 arguments (8 given)
[...]
Event migration done. Migrated 0 of 197988 events.
```

## Steps to Reproduce

1. Have a 9.1.2 onpremise setup and have event data
2. Upgrade to 10 (dev-master), run `install.sh` etc.

### What you expected to happen

Migration scripts succeeds and I have all event data in the new version.

### Possible Solution

Error message suggests a syntax error?



Discussion:
This is the culprit: #17021 //cc @tkaemming 

Working on a fix.

Resolving patch:
diff --git a/src/sentry/migrations/0024_auto_20191230_2052.py b/src/sentry/migrations/0024_auto_20191230_2052.py
--- a/src/sentry/migrations/0024_auto_20191230_2052.py
+++ b/src/sentry/migrations/0024_auto_20191230_2052.py
@@ -86,6 +86,8 @@ def _attach_related(_events):
                 is_regression=False,
                 is_new_group_environment=False,
                 primary_hash=primary_hash,
+                received_timestamp=event.data.get("received")
+                or float(event.datetime.strftime("%s")),
                 skip_consume=True,
             )
             processed += 1


Test patch:
Repository: getsentry/sentry

Issue:
macOS Favicon Dark Mode
I think this one is pretty clear but when using dark mode your website's favicon appears like this:
<img width="28" alt="Screen Shot 2020-06-01 at 10 51 04 AM" src="https://user-images.githubusercontent.com/2802276/83421279-d7240b00-a3f5-11ea-8c0c-015c068a90e8.png">

I wasn't sure where to post this but I figured this would be helpful to someone 👍 .



Discussion:

Resolving patch:
diff --git a/src/sentry/web/frontend/generic.py b/src/sentry/web/frontend/generic.py
--- a/src/sentry/web/frontend/generic.py
+++ b/src/sentry/web/frontend/generic.py
@@ -13,7 +13,7 @@
 NEVER_CACHE = "max-age=0, no-cache, no-store, must-revalidate"
 
 
-def dev_favicon(request):
+def dev_favicon(request, extension):
     document_root, path = resolve("sentry/images/favicon_dev.png")
     return static.serve(request, path, document_root=document_root)
 
diff --git a/src/sentry/web/urls.py b/src/sentry/web/urls.py
--- a/src/sentry/web/urls.py
+++ b/src/sentry/web/urls.py
@@ -64,7 +64,7 @@
 if settings.DEBUG:
     urlpatterns += [
         url(
-            r"^_static/[^/]+/[^/]+/images/favicon\.ico$",
+            r"^_static/[^/]+/[^/]+/images/favicon\.(ico|png)$",
             generic.dev_favicon,
             name="sentry-dev-favicon",
         )


Test patch:
Repository: getsentry/sentry

Issue:
Invalid List-ID header within Sentry Email notifications.
## Important Details

How are you running Sentry?

<!-- Please pick one of the following -->
Saas (sentry.io)


## Description

Email notifications set invalid List-ID headers according to [RFC 2919](https://tools.ietf.org/html/rfc2919)

## Steps to Reproduce

1. Receive an email from sentry.io
1. Look at the raw headers for the email

The header looks like:
```
List-Id: project.team.getsentry.com
```

### What you expected to happen

The List-ID header should be valid, for example:
```
List-Id: <project.team.getsentry.com>
```

### Possible Solution

Add `<>` around your List IDs. Ideally set a display name as well.


Discussion:
Issue is here: https://github.com/getsentry/sentry/blob/1906b119f7f25427c218e3e1b05a9fe0642cd82b/src/sentry/utils/email.py#L231

Resolving patch:
diff --git a/src/sentry/utils/email.py b/src/sentry/utils/email.py
--- a/src/sentry/utils/email.py
+++ b/src/sentry/utils/email.py
@@ -228,7 +228,7 @@ def __call__(self, instance):
         label = ".".join(map(six.text_type, handler(instance)))
         assert is_valid_dot_atom(label)
 
-        return u"{}.{}".format(label, self.__namespace)
+        return u"<{}.{}>".format(label, self.__namespace)
 
 
 default_list_type_handlers = {


Test patch:
diff --git a/tests/sentry/utils/email/tests.py b/tests/sentry/utils/email/tests.py
--- a/tests/sentry/utils/email/tests.py
+++ b/tests/sentry/utils/email/tests.py
@@ -32,7 +32,7 @@ def test_rejects_invalid_types(self):
             self.resolver(object())
 
     def test_generates_list_ids(self):
-        expected = u"{0.project.slug}.{0.organization.slug}.namespace".format(self.event)
+        expected = u"<{0.project.slug}.{0.organization.slug}.namespace>".format(self.event)
         assert self.resolver(self.event.group) == expected
         assert self.resolver(self.event.project) == expected
 
@@ -297,7 +297,7 @@ def test_generates_list_ids_for_registered_types(self):
             MessageBuilder, subject="Test", body="hello world", html_body="<b>hello world</b>"
         )
 
-        expected = u"{event.project.slug}.{event.organization.slug}.{namespace}".format(
+        expected = u"<{event.project.slug}.{event.organization.slug}.{namespace}>".format(
             event=self.event, namespace=options.get("mail.list-namespace")
         )
Repository: getsentry/sentry

Issue:
Hardcoded MAX_RETRIES = 1
https://github.com/getsentry/sentry/blob/master/src/sentry/tasks/deletion.py#L18


Discussion:

Resolving patch:
diff --git a/src/sentry/tasks/deletion.py b/src/sentry/tasks/deletion.py
--- a/src/sentry/tasks/deletion.py
+++ b/src/sentry/tasks/deletion.py
@@ -14,8 +14,7 @@
 
 # in prod we run with infinite retries to recover from errors
 # in debug/development, we assume these tasks generally shouldn't fail
-MAX_RETRIES = 1 if settings.DEBUG else None
-MAX_RETRIES = 1
+MAX_RETRIES = 1 if settings.DEBUG else 5
 
 
 @instrumented_task(name="sentry.tasks.deletion.run_scheduled_deletions", queue="cleanup")


Test patch:
Repository: getsentry/sentry

Issue:
"Create project" in the sentry GUI truncates long project names
If I create a new project with the name "abcdefghi-abcdefghi-abcdefghi-abcdefghi-abcdefghi-" then its name becomes truncated to 30 characters ("abcdefghi-abcdefghi-abcdefghi-"). I am allowed to enter a long project name in the project creation wizard and I am not informed anywhere that the truncation will occur.

Once the project has been created I can successfully rename it to something longer than 30 characters via the project's Project Settings page.


Discussion:

Resolving patch:
diff --git a/src/sentry/api/endpoints/team_projects.py b/src/sentry/api/endpoints/team_projects.py
--- a/src/sentry/api/endpoints/team_projects.py
+++ b/src/sentry/api/endpoints/team_projects.py
@@ -15,7 +15,7 @@
 
 
 class ProjectSerializer(serializers.Serializer):
-    name = serializers.CharField(max_length=64, required=True)
+    name = serializers.CharField(max_length=50, required=True)
     slug = serializers.RegexField(r"^[a-z0-9_\-]+$", max_length=50, required=False, allow_null=True)
     platform = serializers.CharField(required=False, allow_blank=True, allow_null=True)
     default_rules = serializers.BooleanField(required=False, initial=True)
diff --git a/src/sentry/models/project.py b/src/sentry/models/project.py
--- a/src/sentry/models/project.py
+++ b/src/sentry/models/project.py
@@ -138,7 +138,11 @@ def save(self, *args, **kwargs):
             lock = locks.get("slug:project", duration=5)
             with TimedRetryPolicy(10)(lock.acquire):
                 slugify_instance(
-                    self, self.name, organization=self.organization, reserved=RESERVED_PROJECT_SLUGS
+                    self,
+                    self.name,
+                    organization=self.organization,
+                    reserved=RESERVED_PROJECT_SLUGS,
+                    max_length=50,
                 )
             super(Project, self).save(*args, **kwargs)
         else:
@@ -344,7 +348,7 @@ def transfer_to(self, team=None, organization=None):
             with transaction.atomic():
                 self.update(organization=organization)
         except IntegrityError:
-            slugify_instance(self, self.name, organization=organization)
+            slugify_instance(self, self.name, organization=organization, max_length=50)
             self.update(slug=self.slug, organization=organization)
 
         # Both environments and releases are bound at an organization level.


Test patch:
Repository: getsentry/sentry

Issue:
Upgrade from 21.6.1 to 21.6.2 migration error, relation already exists
### Environment

self-hosted (`onpremise` deployment)

### Version

21.6.1 upgrade to 21.6.1

### Steps to Reproduce

1. git fetch tags/21.6.2
2. ./install.sh

### Expected Result

Migration to succeed.

### Actual Result

```
django.db.utils.ProgrammingError: ProgrammingError('relation "sentry_groupedmessage_project_id_id_515aaa7e_uniq" already exists\n',)
SQL: ALTER TABLE "sentry_groupedmessage" ADD CONSTRAINT "sentry_groupedmessage_project_id_id_515aaa7e_uniq" UNIQUE ("project_id", "id")
```


Discussion:

Resolving patch:
diff --git a/src/sentry/migrations/0216_cdc_setup_replication_index.py b/src/sentry/migrations/0216_cdc_setup_replication_index.py
--- a/src/sentry/migrations/0216_cdc_setup_replication_index.py
+++ b/src/sentry/migrations/0216_cdc_setup_replication_index.py
@@ -29,9 +29,33 @@ class Migration(migrations.Migration):
     ]
 
     operations = [
-        migrations.AlterUniqueTogether(
-            name="group",
-            unique_together={("project", "id"), ("project", "short_id")},
+        migrations.SeparateDatabaseAndState(
+            database_operations=[
+                migrations.RunSQL(
+                    """
+                    CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "sentry_groupedmessage_project_id_id_515aaa7e_uniq" ON "sentry_groupedmessage" ("project_id", "id");
+                    """,
+                    reverse_sql="""
+                    DROP INDEX CONCURRENTLY IF EXISTS sentry_groupedmessage_project_id_id_515aaa7e_uniq;
+                    """,
+                    hints={"tables": ["sentry_groupedmessage"]},
+                ),
+                migrations.RunSQL(
+                    """
+                    ALTER TABLE "sentry_groupedmessage" ADD CONSTRAINT "sentry_groupedmessage_project_id_id_515aaa7e_uniq" UNIQUE USING INDEX "sentry_groupedmessage_project_id_id_515aaa7e_uniq";
+                    """,
+                    reverse_sql="""
+                    ALTER TABLE "sentry_groupedmessage" DROP CONSTRAINT IF EXISTS "sentry_groupedmessage_project_id_id_515aaa7e_uniq";
+                    """,
+                    hints={"tables": ["sentry_groupedmessage"]},
+                ),
+            ],
+            state_operations=[
+                migrations.AlterUniqueTogether(
+                    name="group",
+                    unique_together={("project", "id"), ("project", "short_id")},
+                ),
+            ],
         ),
         migrations.RunSQL(
             sql="""


Test patch: