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

Issue:
Built-in support for Canonical's debuginfod to get a symbol server for Ubuntu system symbols
### Problem Statement

We report crashes from our Ubuntu machines, and we need to manually upload symbols for system libraries' debug packages, which is tedious and error prone.

### Solution Brainstorm

Canonical has an official debuginfod service that serves symbols for all officially supported Ubuntu releases: https://ubuntu.com/server/docs/service-debuginfod

It is hosted at https://debuginfod.ubuntu.com -- it would be great if this could be added as a built-in provider, next to Microsoft and Apple.


Discussion:
Assigning to @getsentry/support for [routing](https://open.sentry.io/triage/#2-route), due by **<time datetime=2023-01-27T22:00:00.000Z>Friday, January 27th at 5:00 pm</time> (yyz)**. ⏲️
Routing to @getsentry/owners-native for [triage](https://develop.sentry.dev/processing-tickets/#3-triage), due by **<time datetime=2023-01-31T19:03:44.858Z>Tuesday, January 31st at 11:03 am</time> (sfo)**. ⏲️

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
@@ -2452,6 +2452,29 @@ def build_cdc_postgres_init_db_volume(settings):
         "filters": {"filetypes": ["pdb", "breakpad", "sourcebundle"]},
         "is_public": True,
     },
+    # === Various Linux distributions ===
+    # The `https://debuginfod.elfutils.org/` symbol server is set up to federate
+    # to a bunch of distro-specific servers, and they explicitly state that:
+    # > If your distro offers a server, you may prefer to link to that one directly
+    # In the future, we could add the following servers as well after validating:
+    # - https://debuginfod.opensuse.org/
+    # - https://debuginfod.debian.net/
+    # - https://debuginfod.fedoraproject.org/
+    # - https://debuginfod.archlinux.org/
+    # - https://debuginfod.centos.org/
+    # A couple more servers for less widespread distros are also listed, and there
+    # might be even more that are not listed on that page.
+    # NOTE: The `debuginfod` layout in symbolicator requires the `/buildid/` prefix
+    # to be part of the `url`.
+    "ubuntu": {
+        "type": "http",
+        "id": "sentry:ubuntu",
+        "name": "Ubuntu",
+        "layout": {"type": "debuginfod"},
+        "url": "https://debuginfod.ubuntu.com/buildid/",
+        "filters": {"filetypes": ["elf_code", "elf_debug"]},
+        "is_public": True,
+    },
 }
 
 # Relay


Test patch:
Repository: getsentry/sentry

Issue:
No attachment preview for .log text files
### Environment

SaaS (https://sentry.io/)

### Version

_No response_

### Steps to Reproduce

1. upload a crash report with .log attachment
2. go into issue that was created and scroll to the bottom
3. in attachment section see the .log file and grayed out Preview button for this attachment, hover saying "This attachment cannot be previewed"

### Expected Result

As it is a text file, I would expect this to be the most basic file type able to be previewed without downloading it each time to your drive. I do assume .txt files could be previewed in such way. I see when searching that even image files can be previewed. So .log files 100% should also be previewable...

### Actual Result

Cannot preview this file:
![obraz](https://user-images.githubusercontent.com/5182588/187083496-19f8320a-8c62-4349-b883-b4ecef405dc4.png)



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

Thanks @p0358 i've added that to our backlog, .log files should usually be text.
Any updates on this? This should be simple enough to implement and the lack of it is a bit annoying given the preview feature already exists in the first place but cannot be used...
The problem seems to lay here: https://cs.github.com/getsentry/sentry/blob/fdb70a9719970844a7fd591b321dd9996a5a9437/static/app/components/events/eventAttachments.tsx#L38

In API the mimetype for my .log file is `application/octet-stream` instead of `text/plain`. Interestingly even the class name is `LogFileViewer`. Could this mean the mimetype is dictated by the SDK when the file is being sent?
Actually, the issue seems to lay here: https://cs.github.com/getsentry/sentry/blob/fdb70a9719970844a7fd591b321dd9996a5a9437/src/sentry/models/eventattachment.py?q=mimetype#L53-L61

```python
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimetypes
>>> mimetypes.guess_type("test.log")
(None, None)
>>> mimetypes.guess_type("test.txt")
('text/plain', None)
>>>
```

This library doesn't guess the type for `.log` properly and Sentry falls back to `application/octet-stream`.

**I want to create a PR, would a better course of action be to add some kind of exception right there in Python on backend, or in the frontend function that decides whether attachment preview is available?**

Resolving patch:
diff --git a/src/sentry/runner/settings.py b/src/sentry/runner/settings.py
--- a/src/sentry/runner/settings.py
+++ b/src/sentry/runner/settings.py
@@ -109,6 +109,7 @@ def configure(ctx, py, yaml, skip_service_validation=False):
         ("application/x-font-ttf", "ttc"),
         ("font/opentype", "otf"),
         ("image/svg+xml", "svg"),
+        ("text/plain", "log"),
     ):
         mimetypes.add_type(type, "." + ext)
 


Test patch:
Repository: getsentry/sentry

Issue:
Crons: Increase quota call API Sentry monitors "check-in"
### Problem Statement

Due multi-tenancy was reached quota call API Sentry monitors "check-in":
"You are attempting to use this endpoint too frequently. Limit is 40 requests in 1 seconds"

### Solution Brainstorm

Increase quota call API Sentry monitors "check-in"  at least to 60 requests in 1 seconds


Discussion:
Assigning to @getsentry/support for [routing](https://open.sentry.io/triage/#2-route), due by **<time datetime=2023-03-10T17:33:32.351Z>Friday, March 10th at 12:33</time> (yyz)**. ⏲️
Routing to @getsentry/crons for [triage](https://develop.sentry.dev/processing-tickets/#3-triage), due by **<time datetime=2023-03-14T00:00:00.000Z>Monday, March 13th at 5:00 pm</time> (sfo)**. ⏲️
Hi @mariashulga, could you explain your use case a bit more here? Why do you need so many checkins per second?

Resolving patch:
diff --git a/src/sentry/monitors/endpoints/monitor_ingest_checkin_index.py b/src/sentry/monitors/endpoints/monitor_ingest_checkin_index.py
--- a/src/sentry/monitors/endpoints/monitor_ingest_checkin_index.py
+++ b/src/sentry/monitors/endpoints/monitor_ingest_checkin_index.py
@@ -27,7 +27,9 @@
 )
 from sentry.monitors.serializers import MonitorCheckInSerializerResponse
 from sentry.monitors.validators import MonitorCheckInValidator
+from sentry.ratelimits.config import RateLimitConfig
 from sentry.signals import first_cron_checkin_received, first_cron_monitor_created
+from sentry.types.ratelimit import RateLimit, RateLimitCategory
 from sentry.utils import metrics
 
 from .base import MonitorIngestEndpoint
@@ -41,6 +43,16 @@
 class MonitorIngestCheckInIndexEndpoint(MonitorIngestEndpoint):
     public = {"POST"}
 
+    rate_limits = RateLimitConfig(
+        limit_overrides={
+            "POST": {
+                RateLimitCategory.IP: RateLimit(40 * 60, 60),
+                RateLimitCategory.USER: RateLimit(40 * 60, 60),
+                RateLimitCategory.ORGANIZATION: RateLimit(40 * 60, 60),
+            }
+        },
+    )
+
     @extend_schema(
         operation_id="Create a new check-in",
         parameters=[


Test patch:
Repository: getsentry/sentry

Issue:
Fix logic bug where Group.Status is archived_until_escalating but the GroupInbox.Status is escalating


![Image](https://user-images.githubusercontent.com/10491193/236284761-303ee7f8-c596-4034-b21f-0f44e779e129.png)

## Objective:
We are not transitioning the GroupStatus to escalating but transitioned GroupInboxStatus.


Discussion:

Resolving patch:
diff --git a/src/sentry/issues/escalating.py b/src/sentry/issues/escalating.py
--- a/src/sentry/issues/escalating.py
+++ b/src/sentry/issues/escalating.py
@@ -258,6 +258,7 @@ def is_escalating(group: Group) -> bool:
     if group_hourly_count > forecast_today:
         group.substatus = GroupSubStatus.ESCALATING
         group.status = GroupStatus.UNRESOLVED
+        group.save()
         add_group_to_inbox(group, GroupInboxReason.ESCALATING)
 
         analytics.record(


Test patch:
diff --git a/tests/sentry/issues/test_escalating.py b/tests/sentry/issues/test_escalating.py
--- a/tests/sentry/issues/test_escalating.py
+++ b/tests/sentry/issues/test_escalating.py
@@ -235,15 +235,17 @@ def test_is_escalating_issue(self, record_mock: MagicMock) -> None:
         with self.feature("organizations:escalating-issues"):
             # The group had 6 events in the last hour
             event = self._create_events_for_group(count=6)
-            group_escalating = event.group
-            self.archive_until_escalating(group_escalating)
+            archived_group = event.group
+            self.archive_until_escalating(archived_group)
 
             # The escalating forecast for today is 5, thus, it should escalate
             forecast_values = [5] + [6] * 13
             self.save_mock_escalating_group_forecast(
-                group=group_escalating, forecast_values=forecast_values, date_added=datetime.now()
+                group=archived_group, forecast_values=forecast_values, date_added=datetime.now()
             )
-            assert is_escalating(group_escalating)
+            assert is_escalating(archived_group)
+            group_escalating = Group.objects.get(id=archived_group.id)
+
             record_mock.assert_called_with(
                 "issue.escalating",
                 organization_id=group_escalating.project.organization.id,
Repository: getsentry/sentry

Issue:
Metrics: Track how often we have error messages with key value pairs
This is to track the impact of #49681


Discussion:

Resolving patch:
diff --git a/src/sentry/grouping/strategies/message.py b/src/sentry/grouping/strategies/message.py
--- a/src/sentry/grouping/strategies/message.py
+++ b/src/sentry/grouping/strategies/message.py
@@ -12,6 +12,7 @@
 )
 from sentry.grouping.strategies.similarity_encoders import text_shingle_encoder
 from sentry.interfaces.message import Message
+from sentry.utils import metrics
 
 _irrelevant_re = re.compile(
     r"""(?x)
@@ -99,6 +100,9 @@
 
 
 def trim_message_for_grouping(string: str) -> str:
+    """Replace values from a group's message to hide P.I.I. and improve grouping when no
+    stacktrace available.
+    """
     s = "\n".join(islice((x for x in string.splitlines() if x.strip()), 2)).strip()
     if s != string:
         s += "..."
@@ -106,7 +110,10 @@ def trim_message_for_grouping(string: str) -> str:
     def _handle_match(match: Match[str]) -> str:
         for key, value in match.groupdict().items():
             if value is not None:
-                return "<%s>" % key
+                # key can be one of the keys from _irrelevant_re, thus, not a large cardinality
+                # tracking the key helps distinguish what kinds of replacements are happening
+                metrics.incr("grouping.value_trimmed_from_message", tags={"key": key})
+                return f"<{key}>"
         return ""
 
     return _irrelevant_re.sub(_handle_match, s)


Test patch:
Repository: getsentry/sentry

Issue:
Add feature flag for search shortcuts
ACs:
Should be a flagr flag


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
@@ -1396,6 +1396,8 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
     # sentry at the moment.
     "organizations:issue-search-use-cdc-primary": False,
     "organizations:issue-search-use-cdc-secondary": False,
+    # Adds search suggestions to the issue search bar
+    "organizations:issue-search-shortcuts": False,
     # Enable metric alert charts in email/slack
     "organizations:metric-alert-chartcuterie": False,
     # Extract metrics for sessions during ingestion.
diff --git a/src/sentry/features/__init__.py b/src/sentry/features/__init__.py
--- a/src/sentry/features/__init__.py
+++ b/src/sentry/features/__init__.py
@@ -97,6 +97,7 @@
 default_manager.add("organizations:issue-search-allow-postgres-only-search", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:issue-search-use-cdc-primary", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:issue-search-use-cdc-secondary", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
+default_manager.add("organizations:issue-search-shortcuts", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:js-sdk-dynamic-loader", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:large-debug-files", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
 default_manager.add("organizations:mep-rollout-flag", OrganizationFeature, FeatureHandlerStrategy.REMOTE)


Test patch:
Repository: getsentry/sentry

Issue:
Metric: Per platform support for Group creation to events ratio
The current metric uses [event_manager.save](https://github.com/getsentry/sentry/blob/b5678866f1ba030fbbafafc45546012f84620557/src/sentry/event_manager.py#L387)'s count, however, that includes transactions.

I'm currently cheating the system by using `sentry.event_manager.normalize_stacktraces_for_grouping.count` but that is counting twice.
<img width="1069" alt="image" src="https://github.com/getsentry/sentry/assets/44410/c2a4b9a9-3215-415e-bd3b-94de5e823420">



Discussion:

Resolving patch:
diff --git a/src/sentry/event_manager.py b/src/sentry/event_manager.py
--- a/src/sentry/event_manager.py
+++ b/src/sentry/event_manager.py
@@ -443,6 +443,7 @@ def save(
 
             return jobs[0]["event"]
 
+        # Only error events from this point onward
         with metrics.timer("event_manager.save.organization.get_from_cache"):
             project.set_cached_field_value(
                 "organization", Organization.objects.get_from_cache(id=project.organization_id)
@@ -455,6 +456,9 @@ def save(
         with sentry_sdk.start_span(op="event_manager.save.pull_out_data"):
             _pull_out_data(jobs, projects)
 
+        # This metric can be used to track how many error events there are per platform
+        metrics.incr("save_event.error", tags={"platform": job["event"].platform or "unknown"})
+
         with sentry_sdk.start_span(op="event_manager.save.get_or_create_release_many"):
             _get_or_create_release_many(jobs, projects)
 


Test patch:
Repository: getsentry/sentry

Issue:
SDK Crash Detection: Store Project ID and Event ID
Store project ID and event ID in the SDK crash detection context to find the original SDK crash event, which is only possible with admin Sentry rights.

https://github.com/getsentry/sentry/blob/2c31ee009b44964f78b9e7e8282e602b7ef849b0/src/sentry/utils/sdk_crashes/sdk_crash_detection.py#L40C2-L42


Discussion:

Resolving patch:
diff --git a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py
--- a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py
+++ b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py
@@ -57,7 +57,14 @@ def detect_sdk_crash(self, event: Event, event_project_id: int) -> Optional[Even
             sdk_crash_event_data = strip_event_data(event.data, self.cocoa_sdk_crash_detector)
 
             set_path(
-                sdk_crash_event_data, "contexts", "sdk_crash_detection", value={"detected": True}
+                sdk_crash_event_data,
+                "contexts",
+                "sdk_crash_detection",
+                value={
+                    "detected": True,
+                    "original_project_id": event.project.id,
+                    "original_event_id": event.event_id,
+                },
             )
 
             return self.sdk_crash_reporter.report(sdk_crash_event_data, event_project_id)


Test patch:
diff --git a/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py b/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py
--- a/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py
+++ b/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py
@@ -37,7 +37,11 @@ def execute_test(self, event_data, should_be_reported, mock_sdk_crash_reporter):
             assert mock_sdk_crash_reporter.report.call_count == 1
 
             reported_event_data = mock_sdk_crash_reporter.report.call_args.args[0]
-            assert reported_event_data["contexts"]["sdk_crash_detection"]["detected"] is True
+            assert reported_event_data["contexts"]["sdk_crash_detection"] == {
+                "detected": True,
+                "original_project_id": event.project_id,
+                "original_event_id": event.event_id,
+            }
         else:
             assert mock_sdk_crash_reporter.report.call_count == 0
Repository: getsentry/sentry

Issue:
fix(django): Disable admin on prod
Reported here: https://forum.sentry.io/t/sentry-django-admin-portal/12787?u=byk



Discussion:

Resolving patch:
diff --git a/src/sentry/conf/urls.py b/src/sentry/conf/urls.py
--- a/src/sentry/conf/urls.py
+++ b/src/sentry/conf/urls.py
@@ -29,7 +29,7 @@
     ),
 ]
 
-if "django.contrib.admin" in settings.INSTALLED_APPS:
+if "django.contrib.admin" in settings.INSTALLED_APPS and settings.ADMIN_ENABLED:
     from sentry import django_admin
 
     urlpatterns += django_admin.urlpatterns


Test patch:
Repository: getsentry/sentry

Issue:
Delete unused rules
We have 123,463,89 [rules pending deletion](https://github.com/getsentry/sentry/blob/master/src/sentry/models/rule.py#L21-L25) that must have gotten stuck in the deletion pipeline. We should figure out what's happening / happened and delete them. 


Discussion:

Resolving patch:
diff --git a/src/sentry/migrations/0507_delete_pending_deletion_rules.py b/src/sentry/migrations/0507_delete_pending_deletion_rules.py
new file mode 100644
--- /dev/null
+++ b/src/sentry/migrations/0507_delete_pending_deletion_rules.py
@@ -0,0 +1,41 @@
+# Generated by Django 2.2.28 on 2023-07-06 22:52
+
+from django.db import migrations
+
+from sentry.new_migrations.migrations import CheckedMigration
+from sentry.utils.query import RangeQuerySetWrapperWithProgressBar
+
+
+def delete_rules(apps, schema_editor):
+    from sentry.constants import ObjectStatus
+
+    Rule = apps.get_model("sentry", "Rule")
+    for rule in RangeQuerySetWrapperWithProgressBar(Rule.objects.all()):
+        if rule.status in (ObjectStatus.PENDING_DELETION, ObjectStatus.DISABLED):
+            rule.delete()
+
+
+class Migration(CheckedMigration):
+    # This flag is used to mark that a migration shouldn't be automatically run in production. For
+    # the most part, this should only be used for operations where it's safe to run the migration
+    # after your code has deployed. So this should not be used for most operations that alter the
+    # schema of a table.
+    # Here are some things that make sense to mark as dangerous:
+    # - Large data migrations. Typically we want these to be run manually by ops so that they can
+    #   be monitored and not block the deploy for a long period of time while they run.
+    # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
+    #   have ops run this and not block the deploy. Note that while adding an index is a schema
+    #   change, it's completely safe to run the operation after the code has deployed.
+    is_dangerous = True
+
+    dependencies = [
+        ("sentry", "0506_null_boolean_fields"),
+    ]
+
+    operations = [
+        migrations.RunPython(
+            delete_rules,
+            migrations.RunPython.noop,
+            hints={"tables": ["sentry_rule"]},
+        ),
+    ]


Test patch:
Repository: getsentry/sentry

Issue:
Recently Active Members should be first on the dropdown
When selecting an action for an issue alert, Recently Active Members should be the first option and pre-selected.

![Image](https://user-images.githubusercontent.com/1660873/254756637-1ded483a-d81f-4597-9c14-9c1b3824dad4.png)




Discussion:
thats just your opinion

Resolving patch:
diff --git a/src/sentry/notifications/types.py b/src/sentry/notifications/types.py
--- a/src/sentry/notifications/types.py
+++ b/src/sentry/notifications/types.py
@@ -271,8 +271,8 @@ class FallthroughChoiceType(Enum):
 
 
 FALLTHROUGH_CHOICES = [
-    (FallthroughChoiceType.ALL_MEMBERS.value, "All Project Members"),
     (FallthroughChoiceType.ACTIVE_MEMBERS.value, "Recently Active Members"),
+    (FallthroughChoiceType.ALL_MEMBERS.value, "All Project Members"),
     (FallthroughChoiceType.NO_ONE.value, "No One"),
 ]
 


Test patch:
Repository: getsentry/sentry

Issue:
Add custom referrers when using chartcuterie
we use discover to build the chartcuterie chart. We should add a referrer so we know when we're seeing increased load from chartcuterie.



Discussion:

Resolving patch:
diff --git a/src/sentry/api/endpoints/organization_events_stats.py b/src/sentry/api/endpoints/organization_events_stats.py
--- a/src/sentry/api/endpoints/organization_events_stats.py
+++ b/src/sentry/api/endpoints/organization_events_stats.py
@@ -65,6 +65,7 @@
 
 ALLOWED_EVENTS_STATS_REFERRERS: Set[str] = {
     Referrer.API_ALERTS_ALERT_RULE_CHART.value,
+    Referrer.API_ALERTS_CHARTCUTERIE.value,
     Referrer.API_DASHBOARDS_WIDGET_AREA_CHART.value,
     Referrer.API_DASHBOARDS_WIDGET_BAR_CHART.value,
     Referrer.API_DASHBOARDS_WIDGET_LINE_CHART.value,
diff --git a/src/sentry/incidents/charts.py b/src/sentry/incidents/charts.py
--- a/src/sentry/incidents/charts.py
+++ b/src/sentry/incidents/charts.py
@@ -94,6 +94,7 @@ def fetch_metric_alert_events_timeseries(
             path=f"/organizations/{organization.slug}/events-stats/",
             params={
                 "yAxis": rule_aggregate,
+                "referrer": "api.alerts.chartcuterie",
                 **query_params,
             },
         )
diff --git a/src/sentry/snuba/referrer.py b/src/sentry/snuba/referrer.py
--- a/src/sentry/snuba/referrer.py
+++ b/src/sentry/snuba/referrer.py
@@ -14,6 +14,7 @@ class Referrer(Enum):
     ALERTRULESERIALIZER_TEST_QUERY = "alertruleserializer.test_query"
     API_ALERTS_ALERT_RULE_CHART_METRICS_ENHANCED = "api.alerts.alert-rule-chart.metrics-enhanced"
     API_ALERTS_ALERT_RULE_CHART = "api.alerts.alert-rule-chart"
+    API_ALERTS_CHARTCUTERIE = "api.alerts.chartcuterie"
     API_AUTH_TOKEN_EVENTS_METRICS_ENHANCED_PRIMARY = (
         "api.auth-token.events.metrics-enhanced.primary"
     )


Test patch: