Browse Source

ref: fix erroneously passing code=400 to ValidationError (#62545)

it is always a 400, code is for something else

<!-- Describe your PR here. -->
anthony sottile 1 year ago
parent
commit
ed5ba39d33

+ 0 - 1
pyproject.toml

@@ -386,7 +386,6 @@ module = [
     "sentry.issues.escalating_group_forecast",
     "sentry.issues.ingest",
     "sentry.issues.issue_occurrence",
-    "sentry.issues.merge",
     "sentry.issues.occurrence_consumer",
     "sentry.issues.search",
     "sentry.issues.status_change",

+ 1 - 1
src/sentry/api/endpoints/group_details.py

@@ -352,7 +352,7 @@ class GroupDetailsEndpoint(GroupEndpoint, EnvironmentMixin):
         from sentry.utils import snuba
 
         if group.issue_category != GroupCategory.ERROR:
-            raise ValidationError(detail="Only error issues can be deleted.", code=400)
+            raise ValidationError(detail="Only error issues can be deleted.")
 
         try:
             delete_group_list(request, group.project, [group], "delete")

+ 2 - 2
src/sentry/api/helpers/group_index/update.py

@@ -71,7 +71,7 @@ def handle_discard(
 
     if any(group.issue_category != GroupCategory.ERROR for group in group_list):
         raise rest_framework.exceptions.ValidationError(
-            detail="Only error issues can be discarded.", code=400
+            detail="Only error issues can be discarded."
         )
     # grouped by project_id
     groups_to_delete = defaultdict(list)
@@ -202,7 +202,7 @@ def update_groups(
             },
         )
         if not serializer.is_valid():
-            raise serializers.ValidationError(serializer.errors, code=400)
+            raise serializers.ValidationError(serializer.errors)
 
     if serializer is None:
         return

+ 1 - 3
src/sentry/issues/merge.py

@@ -31,9 +31,7 @@ def handle_merge(
     Returns a dict with the primary group id and a list of the merged group ids.
     """
     if any([group.issue_category != GroupCategory.ERROR for group in group_list]):
-        raise rest_framework.exceptions.ValidationError(
-            detail="Only error issues can be merged.", code=400
-        )
+        raise rest_framework.exceptions.ValidationError(detail="Only error issues can be merged.")
 
     group_list_by_times_seen = sorted(group_list, key=lambda g: (g.times_seen, g.id), reverse=True)
     primary_group, groups_to_merge = group_list_by_times_seen[0], group_list_by_times_seen[1:]