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

Issue:
Make info level issues low severity
Short-circuit the logic for severity for info-level issues to ensure they always are marked low severity. Hard code this as 0 in the event metadata. This applies to all issue types.


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
@@ -2125,6 +2125,10 @@ def _process_existing_aggregate(
 
 
 def _get_severity_score(event: Event) -> float | None:
+    # If the event is info-level or lower, auto-mark as low severity
+    if LOG_LEVELS_MAP[event.data["level"]] <= logging.INFO:
+        return 0
+
     op = "event_manager._get_severity_score"
     logger_data = {"event_id": event.data["event_id"], "op": op}
     severity = None


Test patch:
diff --git a/tests/sentry/event_manager/test_severity.py b/tests/sentry/event_manager/test_severity.py
--- a/tests/sentry/event_manager/test_severity.py
+++ b/tests/sentry/event_manager/test_severity.py
@@ -92,7 +92,7 @@ def test_message_event_simple(
             {"logentry": {"message": "Dogs are great!"}},
         ]
         for case in cases:
-            manager = EventManager(make_event(level="info", **case))
+            manager = EventManager(make_event(**case))
             event = manager.save(self.project.id)
 
             severity = _get_severity_score(event)
@@ -100,7 +100,7 @@ def test_message_event_simple(
             payload = {
                 "message": "Dogs are great!",
                 "has_stacktrace": 0,
-                "log_level": "info",
+                "log_level": "error",
                 "handled": 1,
             }
 
@@ -240,6 +240,29 @@ def test_other_exception(
         )
         assert severity is None
 
+    @patch(
+        "sentry.event_manager.severity_connection_pool.urlopen",
+    )
+    @patch("sentry.event_manager.logger.info")
+    def test_info_events_yield_zero_severity(
+        self,
+        mock_logger_info: MagicMock,
+        mock_urlopen: MagicMock,
+    ) -> None:
+        manager = EventManager(
+            make_event(
+                level="info",
+                exception={"values": [{"type": "InfoEvent", "value": "Super Cool Info"}]},
+            )
+        )
+        event = manager.save(self.project.id)
+
+        severity = _get_severity_score(event)
+        assert severity == 0
+
+        mock_urlopen.assert_not_called()
+        mock_logger_info.assert_not_called()
+
 
 @region_silo_test(stable=True)
 class TestEventManagerSeverity(TestCase):
Repository: getsentry/sentry

Issue:
Remove flag for metric alert rate limiting
Rate limiting was added for metric alerts in #58032 under the options-backed feature flag `"metric_alerts.rate_limit"`. Now we need to test this rate limiting feature internally to make sure it's working as expected and would not cause the metric alert consumer to backlog. 

Once that's all done, the flag should be removed.


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
@@ -1887,8 +1887,6 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
     "organizations:on-demand-metrics-prefill": False,
     # Enable source maps debugger
     "organizations:source-maps-debugger-blue-thunder-edition": False,
-    # Enable metric alert rate limiting
-    "organizations:metric-alert-rate-limiting": False,
     # Enable the new suspect commits calculation that uses all frames in the stack trace
     "organizations:suspect-commits-all-frames": False,
     # Enable logs for debugging weekly reports
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
@@ -108,7 +108,6 @@
 default_manager.add("organizations:mep-rollout-flag", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:metric-alert-chartcuterie", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
 default_manager.add("organizations:metric-alert-ignore-archived", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
-default_manager.add("organizations:metric-alert-rate-limiting", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:metric-alert-threshold-period", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:metrics-extraction", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
 default_manager.add("organizations:more-slow-alerts", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)


Test patch:
Repository: getsentry/sentry

Issue:
Change resolve text to "Resolve" instead of "Resolve in"
The modal reads "resolve in immediately" or "resolve in in the next release" which is a little silly - just remove the word "in" here. 

<img width="530" alt="Screenshot 2024-01-10 at 1 43 24 PM" src="https://github.com/getsentry/sentry/assets/29959063/8cdca567-bf61-4a9b-96e4-54ce0152b35d">



Discussion:

Resolving patch:
diff --git a/src/sentry/integrations/slack/webhooks/action.py b/src/sentry/integrations/slack/webhooks/action.py
--- a/src/sentry/integrations/slack/webhooks/action.py
+++ b/src/sentry/integrations/slack/webhooks/action.py
@@ -292,7 +292,7 @@ def build_resolve_modal_payload(self, callback_id):
             "blocks": [
                 {
                     "type": "section",
-                    "text": {"type": "mrkdwn", "text": "Resolve in"},
+                    "text": {"type": "mrkdwn", "text": "Resolve"},
                     "accessory": {
                         "type": "static_select",
                         "initial_option": {


Test patch:
diff --git a/tests/sentry/integrations/slack/webhooks/actions/__init__.py b/tests/sentry/integrations/slack/webhooks/actions/__init__.py
--- a/tests/sentry/integrations/slack/webhooks/actions/__init__.py
+++ b/tests/sentry/integrations/slack/webhooks/actions/__init__.py
@@ -117,7 +117,7 @@ def post_webhook_block_kit(
                     {
                         "type": "section",
                         "block_id": "a6HD+",
-                        "text": {"type": "mrkdwn", "text": "Resolve in", "verbatim": False},
+                        "text": {"type": "mrkdwn", "text": "Resolve", "verbatim": False},
                         "accessory": {
                             "type": "static_select",
                             "action_id": "static_select-action",
Repository: getsentry/sentry

Issue:
Put import dashboards behind a separate 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
@@ -1503,6 +1503,8 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
     # Delightful Developer Metrics (DDM):
     # Enable sidebar menu item and all UI (requires custom-metrics flag as well)
     "organizations:ddm-ui": False,
+    # Enables import of metric dashboards
+    "organizations:ddm-dashboard-import": False,
     # Enable the default alert at project creation to be the high priority alert
     "organizations:default-high-priority-alerts": False,
     # Enable inbound filters to be turned on by default for new Javascript Projects
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
@@ -89,6 +89,7 @@
 default_manager.add("organizations:dashboards-rh-widget", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:default-inbound-filters", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:ddm-experimental", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
+default_manager.add("organizations:ddm-dashboard-import", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
 default_manager.add("organizations:ddm-ui", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
 default_manager.add("organizations:default-high-priority-alerts", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
 default_manager.add("organizations:derive-code-mappings", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)


Test patch:
Repository: getsentry/sentry

Issue:
Consolidate Intervals in metric widget preview



Discussion:

Resolving patch:
diff --git a/src/sentry/api/serializers/rest_framework/dashboard.py b/src/sentry/api/serializers/rest_framework/dashboard.py
--- a/src/sentry/api/serializers/rest_framework/dashboard.py
+++ b/src/sentry/api/serializers/rest_framework/dashboard.py
@@ -268,7 +268,7 @@ class ThresholdMaxKeys(Enum):
 class DashboardWidgetSerializer(CamelSnakeSerializer[Dashboard]):
     # Is a string because output serializers also make it a string.
     id = serializers.CharField(required=False)
-    title = serializers.CharField(required=False, max_length=255)
+    title = serializers.CharField(required=False, allow_blank=True, max_length=255)
     description = serializers.CharField(
         required=False, max_length=255, allow_null=True, allow_blank=True
     )


Test patch:
Repository: getsentry/sentry

Issue:
Allow OpenAI model to be customized
### Problem Statement

We've noticed that Sentry now has support for AI suggestions inside issues.

We can now already configure our in-house OpenAI endpoint via the `OPENAI_BASE_URL` environment variable, but sadly we cannot configure the model that is used. In our case: `mistral-7b-instruct`. 

See: https://github.com/getsentry/sentry/blob/05e6601a823fb35b21ef8ba79a07da68bf67cb08/src/sentry/api/endpoints/event_ai_suggested_fix.py#L264

Is this something that you would consider adding as a setting?

### Solution Brainstorm

add setting to sentry.conf.py to allow the configuration of the model used.

### Product Area

Issues


Discussion:
Assigning to @getsentry/support for [routing](https://open.sentry.io/triage/#2-route) ⏲️
Routing to @getsentry/product-owners-issues for [triage](https://develop.sentry.dev/processing-tickets/#3-triage) ⏲️
Seems like a reasonable ask. @max-wittig thank you for your suggestion. 

Resolving patch:
diff --git a/src/sentry/api/endpoints/event_ai_suggested_fix.py b/src/sentry/api/endpoints/event_ai_suggested_fix.py
--- a/src/sentry/api/endpoints/event_ai_suggested_fix.py
+++ b/src/sentry/api/endpoints/event_ai_suggested_fix.py
@@ -261,7 +261,7 @@ def describe_event_for_ai(event, model):
     return data
 
 
-def suggest_fix(event_data, model="gpt-3.5-turbo-16k", stream=False):
+def suggest_fix(event_data, model=settings.SENTRY_AI_SUGGESTED_FIX_MODEL, stream=False):
     """Runs an OpenAI request to suggest a fix."""
     prompt = PROMPT.replace("___FUN_PROMPT___", random.choice(FUN_PROMPT_CHOICES))
     event_info = describe_event_for_ai(event_data, model=model)
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
@@ -2407,6 +2407,9 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
 # Secret key for OpenAI
 OPENAI_API_KEY: str | None = None
 
+# AI Suggested Fix default model
+SENTRY_AI_SUGGESTED_FIX_MODEL: str = os.getenv("SENTRY_AI_SUGGESTED_FIX_MODEL", "gpt-3.5-turbo-16k")
+
 SENTRY_API_PAGINATION_ALLOWLIST = SENTRY_API_PAGINATION_ALLOWLIST_DO_NOT_MODIFY
 
 SENTRY_SCOPES = {


Test patch:
Repository: getsentry/sentry

Issue:
Issue Details: Use new assignee selector component
Update issue details to use the new component in https://github.com/getsentry/sentry/issues/69054

This should be released under a short-lived feature flag.


Discussion:

Resolving patch:
diff --git a/fixtures/page_objects/issue_details.py b/fixtures/page_objects/issue_details.py
--- a/fixtures/page_objects/issue_details.py
+++ b/fixtures/page_objects/issue_details.py
@@ -86,9 +86,7 @@ def assign_to(self, user):
         assignee.find_element(by=By.TAG_NAME, value="input").send_keys(user)
 
         # Click the member/team
-        options = assignee.find_elements(
-            by=By.CSS_SELECTOR, value='[data-test-id="assignee-option"]'
-        )
+        options = assignee.find_elements(by=By.CSS_SELECTOR, value='[role="option"]')
         assert len(options) > 0, "No assignees could be found."
         options[0].click()
 


Test patch:
Repository: openedx/ecommerce

Issue:
Running migrations for Travis builds
We run migrations to ensure no migrations are missing, and they work on fresh installs.



Discussion:
@jimabramson @rlucioni @zubair-arbi 

Build will pass once #347 is merged and this branch rebased.

:+1: Reminds me that we should get rid of the `DisableMigrations` hack.


Resolving patch:
diff --git a/ecommerce/extensions/order/migrations/0003_auto_20150224_1520.py b/ecommerce/extensions/order/migrations/0003_auto_20150224_1520.py
--- a/ecommerce/extensions/order/migrations/0003_auto_20150224_1520.py
+++ b/ecommerce/extensions/order/migrations/0003_auto_20150224_1520.py
@@ -13,8 +13,7 @@ def create_shipping_event(apps, schema_editor):
     """
     # Create all our Product Types.
     ShippingEventType = apps.get_model("order", "ShippingEventType")
-    shipped_event = ShippingEventType(code="shipped", name="Shipped")
-    shipped_event.save()
+    ShippingEventType.objects.create(code="shipped", name="Shipped")
 
 
 class Migration(migrations.Migration):


Test patch:
diff --git a/ecommerce/extensions/order/tests/test_processing.py b/ecommerce/extensions/order/tests/test_processing.py
--- a/ecommerce/extensions/order/tests/test_processing.py
+++ b/ecommerce/extensions/order/tests/test_processing.py
@@ -15,7 +15,7 @@ class EventHandlerTests(TestCase):
 
     def setUp(self):
         super(EventHandlerTests, self).setUp()
-        self.shipping_event_type = ShippingEventType.objects.create(name=SHIPPING_EVENT_NAME)
+        self.shipping_event_type, __ = ShippingEventType.objects.get_or_create(name=SHIPPING_EVENT_NAME)
         self.order = factories.create_order()
 
     def test_create_shipping_event_all_lines_complete(self):
diff --git a/ecommerce/settings/test.py b/ecommerce/settings/test.py
--- a/ecommerce/settings/test.py
+++ b/ecommerce/settings/test.py
@@ -13,34 +13,6 @@
 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
 
 LOGGING = get_logger_config(debug=DEBUG, dev_env=True, local_loglevel='DEBUG')
-
-
-class DisableMigrations(object):
-    """Override method calls on the MIGRATION_MODULES dictionary.
-
-    If the `makemigrations` command has not been run for an app, the
-    `migrate` command treats that app as unmigrated, creating tables
-    directly from the models just like the now-defunct `syncdb` command
-    used to do. These overrides are used to force Django to treat apps
-    in this project as unmigrated.
-
-    Django 1.8 features the `--keepdb` flag for exactly this purpose,
-    but we don't have that luxury in 1.7.
-
-    For more context, see http://goo.gl/Fr4qyE.
-    """
-
-    def __contains__(self, item):
-        """Make it appear as if all apps are contained in the dictionary."""
-        return True
-
-    def __getitem__(self, item):
-        """Force Django to look for migrations in a nonexistent package."""
-        return 'notmigrations'
-
-
-if str(os.environ.get('DISABLE_MIGRATIONS')) == 'True':
-    MIGRATION_MODULES = DisableMigrations()
 # END TEST SETTINGS
Repository: netbox-community/netbox

Issue:
Invalid rack group when importing
When trying to use the text box for CSV to import racks I get:

```
Record 1 (group): Invalid rack group (site01 - group01)
```

So I manually added a single rack to the group, exported it, then tried re-importing it only to face the same issue.

```
site01,group01,r00,site01.r00,42
```



Discussion:

Resolving patch:
diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py
--- a/netbox/dcim/filters.py
+++ b/netbox/dcim/filters.py
@@ -47,6 +47,12 @@ class RackFilter(django_filters.FilterSet):
         queryset=RackGroup.objects.all(),
         label='Group (ID)',
     )
+    group = django_filters.ModelMultipleChoiceFilter(
+        name='group',
+        queryset=RackGroup.objects.all(),
+        to_field_name='slug',
+        label='Group',
+    )
 
     class Meta:
         model = Rack
diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py
--- a/netbox/dcim/forms.py
+++ b/netbox/dcim/forms.py
@@ -138,24 +138,23 @@ def __init__(self, *args, **kwargs):
 class RackFromCSVForm(forms.ModelForm):
     site = forms.ModelChoiceField(queryset=Site.objects.all(), to_field_name='name',
                                   error_messages={'invalid_choice': 'Site not found.'})
-    group = forms.ModelChoiceField(queryset=RackGroup.objects.all(), required=False, to_field_name='name',
-                                   error_messages={'invalid_choice': 'Group not found.'})
+    group_name = forms.CharField(required=False)
 
     class Meta:
         model = Rack
-        fields = ['site', 'group', 'name', 'facility_id', 'u_height']
+        fields = ['site', 'group_name', 'name', 'facility_id', 'u_height']
 
     def clean(self):
 
         site = self.cleaned_data.get('site')
-        group = self.cleaned_data.get('group')
+        group = self.cleaned_data.get('group_name')
 
-        # Validate device type
+        # Validate rack group
         if site and group:
             try:
                 self.instance.group = RackGroup.objects.get(site=site, name=group)
             except RackGroup.DoesNotExist:
-                self.add_error('group', "Invalid rack group ({})".format(group))
+                self.add_error('group_name', "Invalid rack group ({})".format(group))
 
 
 class RackImportForm(BulkImportForm, BootstrapMixin):


Test patch:
Repository: netbox-community/netbox

Issue:
Typo in /dcim/views.py
Line 356:

```
messages.success(request, "Added {} compontent(s) to {}".format(len(component_templates), devicetype))
```

compontent -> component



Discussion:

Resolving patch:
diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py
--- a/netbox/dcim/models.py
+++ b/netbox/dcim/models.py
@@ -183,6 +183,16 @@ def __unicode__(self):
     def get_absolute_url(self):
         return reverse('dcim:rack', args=[self.pk])
 
+    def clean(self):
+
+        # Validate that Rack is tall enough to house the installed Devices
+        if self.pk:
+            top_device = Device.objects.filter(rack=self).order_by('-position').first()
+            min_height = top_device.position + top_device.device_type.u_height - 1
+            if self.u_height < min_height:
+                raise ValidationError("Rack must be at least {}U tall with currently installed devices."
+                                      .format(min_height))
+
     def to_csv(self):
         return ','.join([
             self.site.name,
diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -353,7 +353,7 @@ def post(self, request, pk):
 
             if not form.errors:
                 self.model.objects.bulk_create(component_templates)
-                messages.success(request, "Added {} compontent(s) to {}".format(len(component_templates), devicetype))
+                messages.success(request, "Added {} component(s) to {}".format(len(component_templates), devicetype))
                 if '_addanother' in request.POST:
                     return redirect(request.path)
                 else:
diff --git a/netbox/utilities/forms.py b/netbox/utilities/forms.py
--- a/netbox/utilities/forms.py
+++ b/netbox/utilities/forms.py
@@ -19,11 +19,11 @@ def expand_pattern(string):
     lead, pattern, remnant = re.split(EXPANSION_PATTERN, string, maxsplit=1)
     x, y = pattern.split('-')
     for i in range(int(x), int(y) + 1):
-        if remnant:
+        if re.search(EXPANSION_PATTERN, remnant):
             for string in expand_pattern(remnant):
                 yield "{}{}{}".format(lead, i, string)
         else:
-            yield "{}{}".format(lead, i)
+            yield "{}{}{}".format(lead, i, remnant)
 
 
 #


Test patch:
Repository: netbox-community/netbox

Issue:
Reducing a rack's height lower than that of an installed device results in an error
It is possible to create a rack, install a device in the top unit of that rack, and then reduce the rack's height so that the device cannot exist. This results in a server error.



Discussion:

Resolving patch:
diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py
--- a/netbox/dcim/models.py
+++ b/netbox/dcim/models.py
@@ -188,10 +188,11 @@ def clean(self):
         # Validate that Rack is tall enough to house the installed Devices
         if self.pk:
             top_device = Device.objects.filter(rack=self).order_by('-position').first()
-            min_height = top_device.position + top_device.device_type.u_height - 1
-            if self.u_height < min_height:
-                raise ValidationError("Rack must be at least {}U tall with currently installed devices."
-                                      .format(min_height))
+            if top_device:
+                min_height = top_device.position + top_device.device_type.u_height - 1
+                if self.u_height < min_height:
+                    raise ValidationError("Rack must be at least {}U tall with currently installed devices."
+                                          .format(min_height))
 
     def to_csv(self):
         return ','.join([
diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py
--- a/netbox/ipam/views.py
+++ b/netbox/ipam/views.py
@@ -395,16 +395,24 @@ def ipaddress(request, pk):
 
     ipaddress = get_object_or_404(IPAddress.objects.select_related('interface__device'), pk=pk)
 
+    # Parent prefixes table
     parent_prefixes = Prefix.objects.filter(vrf=ipaddress.vrf, prefix__net_contains=str(ipaddress.address.ip))
-    related_ips = IPAddress.objects.select_related('interface__device').exclude(pk=ipaddress.pk)\
-        .filter(vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address))
+    parent_prefixes_table = tables.PrefixBriefTable(parent_prefixes)
 
+    # Duplicate IPs table
+    duplicate_ips = IPAddress.objects.filter(vrf=ipaddress.vrf, address=str(ipaddress.address))\
+        .exclude(pk=ipaddress.pk).select_related('interface__device', 'nat_inside')
+    duplicate_ips_table = tables.IPAddressBriefTable(duplicate_ips)
+
+    # Related IP table
+    related_ips = IPAddress.objects.select_related('interface__device').exclude(address=str(ipaddress.address))\
+        .filter(vrf=ipaddress.vrf, address__net_contained_or_equal=str(ipaddress.address))
     related_ips_table = tables.IPAddressBriefTable(related_ips)
-    RequestConfig(request, paginate={'klass': EnhancedPaginator}).configure(related_ips_table)
 
     return render(request, 'ipam/ipaddress.html', {
         'ipaddress': ipaddress,
-        'parent_prefixes': parent_prefixes,
+        'parent_prefixes_table': parent_prefixes_table,
+        'duplicate_ips_table': duplicate_ips_table,
         'related_ips_table': related_ips_table,
     })
 


Test patch: