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

Issue:
fix(dev): Use full path for Kafka container
Follow up to #28574.

When we [upgraded the kafka and zookeeper images we use][1], we did not update the volume to
use the full path (as the [instructions indicate][2]), thus, started to see this error:

>  Command [/usr/local/bin/dub path /var/lib/kafka/data writable] FAILED !

This change adds the full path.

[1]: https://github.com/getsentry/sentry/pull/28574
[2]: https://docs.confluent.io/platform/current/installation/docker/operations/external-volumes.html#data-volumes-for-kafka-and-zk
Docker Kafka container restarting on Mac intel processor
### Environment

self-hosted (`onpremise` deployment)

### Version

21.10.0.dev0

### Steps to Reproduce

1. Clone from GitHub `master` branch
2. Follow instructions at https://develop.sentry.dev/environment/ to setup environment
3. `sentry upgrade`, `sentry devservices up` `sentry devserver --workers`
4. Observe Docker containers, specifically sentry_kafka

Using MacBook Pro 2020 w/ Intel Core, Docker v20.10.8

### Expected Result

Containers are all running and user is able to navigate to localhost:8000 and view new errors for current projects.

### Actual Result

The Kafka container is repeatedly restarting. When I trigger an event for a project, I do not see any events on the issues dashboard.

<img width="1054" alt="Screen Shot 2021-10-01 at 5 21 05 PM" src="https://user-images.githubusercontent.com/16708871/135687659-d6fe8ca5-b255-4546-aeff-68cf9cba416f.png">




Discussion:

Resolving patch:
diff --git a/src/sentry/conf/server.py b/src/sentry/conf/server.py
--- a/src/sentry/conf/server.py
+++ b/src/sentry/conf/server.py
@@ -1748,9 +1748,7 @@ def build_cdc_postgres_init_db_volume(settings):
     ),
     "zookeeper": lambda settings, options: (
         {
-            # Upgrading to version 6.x allows zookeeper to run properly on Apple's arm64
-            # See details https://github.com/confluentinc/kafka-images/issues/80#issuecomment-855511438
-            "image": "confluentinc/cp-zookeeper:6.2.0",
+            "image": "confluentinc/cp-zookeeper:5.1.2",
             "environment": {"ZOOKEEPER_CLIENT_PORT": "2181"},
             "volumes": {"zookeeper": {"bind": "/var/lib/zookeeper"}},
             "only_if": "kafka" in settings.SENTRY_EVENTSTREAM or settings.SENTRY_USE_RELAY,
@@ -1758,8 +1756,7 @@ def build_cdc_postgres_init_db_volume(settings):
     ),
     "kafka": lambda settings, options: (
         {
-            # We upgrade to version 6.x to match zookeeper's version (I believe they both release together)
-            "image": "confluentinc/cp-kafka:6.2.0",
+            "image": "confluentinc/cp-kafka:5.1.2",
             "ports": {"9092/tcp": 9092},
             "environment": {
                 "KAFKA_ZOOKEEPER_CONNECT": "{containers[zookeeper][name]}:2181",


Test patch:
Repository: getsentry/sentry

Issue:
Zookeper Docker image not working on Apple's arm64
We currently run 5.1.2 which is a couple of years old and does not run well on Apple M1's.

We could upgrade kafka and zookeeper to 6.2.0 where qemu panics don't happen.

We could also try not using zookeeper at all. See:
https://www.confluent.io/blog/kafka-without-zookeeper-a-sneak-peek/
https://github.com/getsentry/sentry/pull/28568


Discussion:
Upgrading to 6.2.0 seems to have fixed the issue.

Resolving patch:
diff --git a/src/sentry/conf/server.py b/src/sentry/conf/server.py
--- a/src/sentry/conf/server.py
+++ b/src/sentry/conf/server.py
@@ -9,6 +9,7 @@
 import sys
 import tempfile
 from datetime import timedelta
+from platform import platform
 from urllib.parse import urlparse
 
 from django.conf.global_settings import *  # NOQA
@@ -1700,6 +1701,8 @@ def build_cdc_postgres_init_db_volume(settings):
     )
 
 
+APPLE_ARM64 = platform().startswith("mac") and platform().endswith("arm64-arm-64bit")
+
 SENTRY_DEVSERVICES = {
     "redis": lambda settings, options: (
         {
@@ -1752,7 +1755,13 @@ def build_cdc_postgres_init_db_volume(settings):
     ),
     "zookeeper": lambda settings, options: (
         {
-            "image": "confluentinc/cp-zookeeper:5.1.2",
+            # On Apple arm64, we upgrade to version 6.x allows zookeeper to run properly on Apple's arm64
+            # See details https://github.com/confluentinc/kafka-images/issues/80#issuecomment-855511438
+            # I'm selectively upgrading the version on Apple's arm64 since there was a bug that only affects
+            # Intel machines. For more details see: https://github.com/getsentry/sentry/pull/28672
+            "image": "confluentinc/cp-zookeeper:6.2.0"
+            if APPLE_ARM64
+            else "confluentinc/cp-zookeeper:5.1.2",
             "environment": {"ZOOKEEPER_CLIENT_PORT": "2181"},
             "volumes": {"zookeeper": {"bind": "/var/lib/zookeeper"}},
             "only_if": "kafka" in settings.SENTRY_EVENTSTREAM or settings.SENTRY_USE_RELAY,
@@ -1760,7 +1769,10 @@ def build_cdc_postgres_init_db_volume(settings):
     ),
     "kafka": lambda settings, options: (
         {
-            "image": "confluentinc/cp-kafka:5.1.2",
+            # On Apple arm64, we upgrade to version 6.x to match zookeeper's version (I believe they both release together)
+            "image": "confluentinc/cp-kafka:6.2.0"
+            if APPLE_ARM64
+            else "confluentinc/cp-kafka:5.1.2",
             "ports": {"9092/tcp": 9092},
             "environment": {
                 "KAFKA_ZOOKEEPER_CONNECT": "{containers[zookeeper][name]}:2181",


Test patch:
Repository: getsentry/sentry

Issue:
Add audit logging for isSuperuser/isStaff changes



Discussion:

Resolving patch:
diff --git a/src/sentry/api/endpoints/user_details.py b/src/sentry/api/endpoints/user_details.py
--- a/src/sentry/api/endpoints/user_details.py
+++ b/src/sentry/api/endpoints/user_details.py
@@ -4,6 +4,7 @@
 import pytz
 from django.conf import settings
 from django.contrib.auth import logout
+from django.db import transaction
 from django.utils.translation import ugettext_lazy as _
 from rest_framework import serializers, status
 from rest_framework.response import Response
@@ -19,6 +20,7 @@
 from sentry.constants import LANGUAGES
 from sentry.models import Organization, OrganizationMember, OrganizationStatus, User, UserOption
 
+audit_logger = logging.getLogger("sentry.audit.user")
 delete_logger = logging.getLogger("sentry.deletions.api")
 
 
@@ -171,7 +173,18 @@ def put(self, request, user):
                     user=user, key=key_map.get(key, key), value=options_result.get(key)
                 )
 
-        user = serializer.save()
+        with transaction.atomic():
+            user = serializer.save()
+
+            if any(k in request.data for k in ("isStaff", "isSuperuser", "isActive")):
+                audit_logger.info(
+                    "user.edit",
+                    extra={
+                        "user_id": user.id,
+                        "actor_id": request.user.id,
+                        "form_data": request.data,
+                    },
+                )
 
         return Response(serialize(user, request.user, DetailedUserSerializer()))
 


Test patch:
Repository: getsentry/sentry

Issue:
Still receiving weekly reports even if my account is deactivated
### Environment

SaaS (https://sentry.io/)

### Version

_No response_

### Steps to Reproduce

IDK, I was a part of an organization in Sentry but this organization is right now on a plan that supports only 1 member and I can't remove myself from it to not receive those emails anymore.

### Expected Result

I should not get any report emails if I'm deactivated member of an organization.

### Actual Result

I'm constantly getting weekly report emails as a deactivated member of an organisation.


![image](https://user-images.githubusercontent.com/2932563/146765142-6e057850-9e43-402d-ab49-cbe421d80c67.png)


![image](https://user-images.githubusercontent.com/2932563/146765236-96e63308-2641-4684-99ec-94ea4a8aa848.png)



Discussion:
Routing to @getsentry/workflow for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️

Routing to @getsentry/ecosystem for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️

Routing to @getsentry/growth for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️

Routing to @getsentry/growth for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️

I added this to growth and ecosystem because I think it could be related to work from either team. I think growth worked on this disabling of users when downgrading?
@wedamija Not 100% sure if this is growth, but we are going to work on weekly emails so we can take it.

Resolving patch:
diff --git a/src/sentry/tasks/reports.py b/src/sentry/tasks/reports.py
--- a/src/sentry/tasks/reports.py
+++ b/src/sentry/tasks/reports.py
@@ -11,6 +11,7 @@
 from typing import Iterable, Mapping, NamedTuple, Tuple
 
 import pytz
+from django.db.models import F
 from django.urls.base import reverse
 from django.utils import dateformat, timezone
 from django.utils.http import urlencode
@@ -33,6 +34,7 @@
     GroupHistory,
     GroupStatus,
     Organization,
+    OrganizationMember,
     OrganizationStatus,
     Project,
     Team,
@@ -797,7 +799,9 @@ def prepare_organization_report(timestamp, duration, organization_id, dry_run=Fa
 
     # If an OrganizationMember row doesn't have an associated user, this is
     # actually a pending invitation, so no report should be delivered.
-    member_set = organization.member_set.filter(user_id__isnull=False, user__is_active=True)
+    member_set = organization.member_set.filter(
+        user_id__isnull=False, user__is_active=True
+    ).exclude(flags=F("flags").bitor(OrganizationMember.flags["member-limit:restricted"]))
 
     for user_id in member_set.values_list("user_id", flat=True):
         deliver_organization_user_report.delay(


Test patch:
Repository: getsentry/sentry

Issue:
Cannot edit or delete alerts
### Environment

SaaS (https://sentry.io/)

### Version

_No response_

### Steps to Reproduce

1. Have alerts that were set up a while ago
2. Get a bunch of emails from one alert that is too touchy
3. Try to edit alert (fails)
4. Try to delete alert (fails)

### Expected Result

Can edit or delete alerts that I created on an account that I am the only user for

### Actual Result

Cannot edit or delete alerts

![ksnip_20220729-153917](https://user-images.githubusercontent.com/22881850/183306578-20fe738c-96b1-4052-a308-ad49c7febbe7.png)

![ksnip_20220807-115243](https://user-images.githubusercontent.com/22881850/183306642-6299edea-28e0-46fb-a98b-387662bc0c0b.png)




Discussion:
Routing to @getsentry/workflow for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️

Thanks for reporting. Looks related to your account billing/plan. You should be able to delete them, will look into this.

Resolving patch:
diff --git a/src/sentry/incidents/endpoints/bases.py b/src/sentry/incidents/endpoints/bases.py
--- a/src/sentry/incidents/endpoints/bases.py
+++ b/src/sentry/incidents/endpoints/bases.py
@@ -38,7 +38,10 @@ def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):
         args, kwargs = super().convert_args(request, *args, **kwargs)
         organization = kwargs["organization"]
 
-        if not features.has("organizations:incidents", organization, actor=request.user):
+        # Allow orgs that have downgraded plans to delete metric alerts
+        if request.method != "DELETE" and not features.has(
+            "organizations:incidents", organization, actor=request.user
+        ):
             raise ResourceDoesNotExist
 
         try:


Test patch:
diff --git a/tests/sentry/incidents/endpoints/test_organization_alert_rule_details.py b/tests/sentry/incidents/endpoints/test_organization_alert_rule_details.py
--- a/tests/sentry/incidents/endpoints/test_organization_alert_rule_details.py
+++ b/tests/sentry/incidents/endpoints/test_organization_alert_rule_details.py
@@ -520,6 +520,13 @@ def test_simple(self):
         assert not AlertRule.objects_with_snapshots.filter(name=self.alert_rule.name).exists()
         assert not AlertRule.objects_with_snapshots.filter(id=self.alert_rule.id).exists()
 
+    def test_no_feature(self):
+        self.create_member(
+            user=self.user, organization=self.organization, role="owner", teams=[self.team]
+        )
+        self.login_as(self.user)
+        self.get_success_response(self.organization.slug, self.alert_rule.id, status_code=204)
+
     def test_snapshot_and_create_new_with_same_name(self):
         with self.tasks():
             self.create_member(
Repository: getsentry/sentry

Issue:
Can't add a new column to Organization
### Environment

self-hosted (https://develop.sentry.dev/self-hosted/)

### Version

_No response_

### Steps to Reproduce

1. Add a new column to organization
2. Try to make a new migration using `sentry django makemigration`

### Expected Result

Makemigration should generate a new migration file.

### Actual Result

Generation fails due to makemigrations loading the SDK.  This in turn hits this line of code for feature checking:
https://github.com/getsentry/sentry/blob/ad99c1fe7d7378c3761bad757aacf27352c693a6/src/sentry/models/projectkey.py#L249-L259




Discussion:

Resolving patch:
diff --git a/src/sentry/models/projectkey.py b/src/sentry/models/projectkey.py
--- a/src/sentry/models/projectkey.py
+++ b/src/sentry/models/projectkey.py
@@ -4,7 +4,7 @@
 
 import petname
 from django.conf import settings
-from django.db import models, transaction
+from django.db import ProgrammingError, models, transaction
 from django.urls import reverse
 from django.utils import timezone
 from django.utils.translation import ugettext_lazy as _
@@ -246,7 +246,16 @@ def get_endpoint(self, public=True):
         if not endpoint:
             endpoint = options.get("system.url-prefix")
 
-        if features.has("organizations:org-subdomains", self.project.organization):
+        has_org_subdomain = False
+        try:
+            has_org_subdomain = features.has(
+                "organizations:org-subdomains", self.project.organization
+            )
+        except ProgrammingError:
+            # This happens during migration generation for the organization model.
+            pass
+
+        if has_org_subdomain:
             urlparts = urlparse(endpoint)
             if urlparts.scheme and urlparts.netloc:
                 endpoint = "{}://{}.{}{}".format(


Test patch:
Repository: getsentry/sentry

Issue:
pip-compile and CUSTOM_COMPILE_COMMAND
### Environment

SaaS (https://sentry.io/)

### Version

_No response_

### Steps to Reproduce

JFYI

https://github.com/getsentry/sentry/blob/2e36d4d3a3926e9efe06287e59d27be1c40300fa/tools/freeze_requirements.py#L13

There is `CUSTOM_COMPILE_COMMAND` env to [customize](https://github.com/jazzband/pip-tools#configuration) the header:


```
$ CUSTOM_COMPILE_COMMAND="make freeze-requirements" pip-compile
#
# This file is autogenerated by pip-compile with python 3.11
# To update, run:
#
#    make freeze-requirements
#
....
```

### Expected Result

N/A

### Actual Result

N/A


Discussion:
@atugushev would you be interested in sending a quick patch?
@asottile-sentry sure, I'd love to. I'll open a PR then.
[Failed](https://github.com/getsentry/sentry/actions/runs/3464012141) to route to `Team: Dev Infrastructure`.  😕

Defaulting to @getsentry/open-source for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️

Routing to @getsentry/dev-infra for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️


Resolving patch:
diff --git a/tools/freeze_requirements.py b/tools/freeze_requirements.py
--- a/tools/freeze_requirements.py
+++ b/tools/freeze_requirements.py
@@ -1,6 +1,7 @@
 from __future__ import annotations
 
 import argparse
+import os
 from concurrent.futures import Future, ThreadPoolExecutor
 from os.path import abspath
 from subprocess import CalledProcessError, run
@@ -10,25 +11,10 @@
 
 
 def worker(args: tuple[str, ...]) -> None:
-    # pip-compile doesn't let you customize the header, so we write
-    # one ourselves. However, pip-compile needs -o DEST otherwise
-    # it will bump >= pins even if they're satisfied. So, we need to
-    # unfortunately rewrite the whole file.
-    dest = args[-1]
-    try:
-        run(args, check=True, capture_output=True)
-    except CalledProcessError as e:
-        raise e
-
-    with open(dest, "rb+") as f:
-        content = f.read()
-        f.seek(0, 0)
-        f.write(
-            b"""# DO NOT MODIFY. This file was generated with `make freeze-requirements`.
+    env = os.environ.copy()
+    env["CUSTOM_COMPILE_COMMAND"] = "make freeze-requirements"
 
-"""
-            + content
-        )
+    run(args, check=True, capture_output=True, env=env)
 
 
 def check_futures(futures: list[Future[None]]) -> int:
@@ -61,7 +47,6 @@ def main(argv: Sequence[str] | None = None) -> int:
         "pip-compile",
         "--allow-unsafe",
         "--no-annotate",
-        "--no-header",
         "--quiet",
         "--strip-extras",
         "--index-url=https://pypi.devinfra.sentry.io/simple",


Test patch:
Repository: getsentry/sentry

Issue:
Fix flaky performance issue acceptance test
Fix the email acceptance test for performance issues. It seems like the hardcoded timestamp isn't being respected.

https://github.com/getsentry/sentry/pull/42383
https://storage.googleapis.com/sentry-visual-snapshots/getsentry/sentry/5917292eb19b60c9ca477059af667154a60165e4/index.html#acceptance-mobile-performance-email-html-png


Discussion:

Resolving patch:
diff --git a/src/sentry/web/frontend/debug/mail.py b/src/sentry/web/frontend/debug/mail.py
--- a/src/sentry/web/frontend/debug/mail.py
+++ b/src/sentry/web/frontend/debug/mail.py
@@ -197,7 +197,7 @@ def make_performance_event(project):
         perf_data = dict(
             load_data(
                 "transaction-n-plus-one",
-                timestamp=datetime(2022, 11, 11, 21, 39, 23, 30723),
+                timestamp=datetime(2017, 9, 6, 0, 0),
             )
         )
         perf_data["event_id"] = "44f1419e73884cd2b45c79918f4b6dc4"
@@ -205,6 +205,8 @@ def make_performance_event(project):
         perf_event_manager.normalize()
         perf_data = perf_event_manager.get_data()
         perf_event = perf_event_manager.save(project.id)
+        # Prevent CI screenshot from constantly changing
+        perf_event.data["timestamp"] = 1504656000.0  # datetime(2017, 9, 6, 0, 0)
 
     perf_event = perf_event.for_group(perf_event.groups[0])
     return perf_event


Test patch:
diff --git a/tests/acceptance/test_emails.py b/tests/acceptance/test_emails.py
--- a/tests/acceptance/test_emails.py
+++ b/tests/acceptance/test_emails.py
@@ -19,7 +19,7 @@
     ("/debug/mail/unable-to-fetch-commits/", "unable to fetch commits"),
     ("/debug/mail/unable-to-delete-repo/", "unable to delete repo"),
     ("/debug/mail/error-alert/", "alert"),
-    # ("/debug/mail/performance-alert/", "performance"), TODO: Flaky: GRW-778
+    ("/debug/mail/performance-alert/", "performance"),
     ("/debug/mail/digest/", "digest"),
     ("/debug/mail/invalid-identity/", "invalid identity"),
     ("/debug/mail/invitation/", "invitation"),
Repository: getsentry/sentry

Issue:
Password set policy
<!--

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

Also note that the Sentry team has finite resources and priorities that are not
always visible on GitHub. If your issue doesn't align with our priorities it's
unlikely it will be worked on. If we're interested in a particular feature however,
we'll follow up and ask you to submit an RFC to talk about it in more detail.

-->

## Possibility to enable password set policy

Recently found that some team members use simple passwords like 123456. By far the only default restriction is 6 letter length. It'd be great if administrators can specify password requirements like (at least 1 uppercase letter, at least 1 digit)



Discussion:
Closing this issue due to staleness. Feel free to comment here if you think we should still work on this.
@BYK this is still use case for us.
@Bessonov I understand. It is just very unlikely that this will be picked up by anyone soon or ever to be honest. Instead of having a system for password requirements configuration I think an easier thing to do would be adding a password-strength meter.
It would be nice to have a configuration for password requirements, but a single boolean to activate strong passwords (topic to define) would be enough.

If you think of a password-strength meter, then I can imagine to have a static definition of "weak", "good" and "strong" password and let admin define which level is necessary with an select control. But I'm also fine if it's forced client side only.

The main problem why this is needed, it's because sentry must be public to get events from apps or websites. Is there any way to let event API public and hide developer/admin login?
Any news about this issue ?
I'll reopen as this might be something we'll look into. That said there are no solid plans or timeline yet.

Resolving patch:
diff --git a/src/sentry/conf/server.py b/src/sentry/conf/server.py
--- a/src/sentry/conf/server.py
+++ b/src/sentry/conf/server.py
@@ -435,14 +435,21 @@ def env(key, default="", type=None):
 )
 
 AUTH_PASSWORD_VALIDATORS = [
+    {"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
     {
         "NAME": "sentry.auth.password_validation.MinimumLengthValidator",
-        "OPTIONS": {"min_length": 6},
+        "OPTIONS": {"min_length": 8},
     },
     {
         "NAME": "sentry.auth.password_validation.MaximumLengthValidator",
         "OPTIONS": {"max_length": 256},
     },
+    {
+        "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
+    },
+    {
+        "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
+    },
 ]
 
 SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL = "sentry.User"


Test patch: