Skip to content

Commit bd50ca9

Browse files
committed
fixes
1 parent 7ec2d66 commit bd50ca9

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/sentry/workflow_engine/endpoints/organization_data_condition_index.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from typing import NotRequired, TypedDict
22

33
from drf_spectacular.utils import extend_schema
4-
from rest_framework import serializers, status
5-
from rest_framework.response import Response
4+
from rest_framework import serializers
65

76
from sentry.api.api_owners import ApiOwner
87
from sentry.api.api_publish_status import ApiPublishStatus
@@ -19,17 +18,11 @@
1918
from sentry.apidocs.parameters import GlobalParams
2019
from sentry.apidocs.utils import inline_sentry_response_serializer
2120
from sentry.workflow_engine.endpoints.serializers import DataConditionHandlerSerializer
22-
from sentry.workflow_engine.models.data_condition import IGNORED_CONDITIONS
21+
from sentry.workflow_engine.models.data_condition import LEGACY_CONDITIONS
2322
from sentry.workflow_engine.registry import condition_handler_registry
2423
from sentry.workflow_engine.types import DataConditionHandler
2524

2625

27-
class DataConditionRequestSerializer(serializers.Serializer):
28-
type = serializers.ChoiceField(
29-
choices=[type.value for type in DataConditionHandler.Type],
30-
)
31-
32-
3326
class DataConditionHandlerResponse(TypedDict):
3427
condition_id: str
3528
type: str
@@ -63,17 +56,16 @@ def get(self, request, organization):
6356
"""
6457
Returns a list of data conditions for a given org
6558
"""
66-
serializer = DataConditionRequestSerializer(data=request.GET)
67-
if not serializer.is_valid():
68-
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
69-
serialized = serializer.validated_data
70-
71-
type = serialized.get("type")
59+
type = request.GET.get("type")
60+
try:
61+
DataConditionHandler.Type(type)
62+
except ValueError:
63+
raise serializers.ValidationError("Invalid group")
7264

7365
data_conditions = []
7466

7567
for condition, handler in condition_handler_registry.registrations.items():
76-
if condition not in IGNORED_CONDITIONS and handler.type == type:
68+
if condition not in LEGACY_CONDITIONS and handler.type == type:
7769
condition_json = {"condition_id": condition}
7870

7971
condition_json.update(

src/sentry/workflow_engine/models/data_condition.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Condition(StrEnum):
8383
] + PERCENT_CONDITIONS
8484

8585
# Conditions that are not supported in the UI
86-
IGNORED_CONDITIONS = [
86+
LEGACY_CONDITIONS = [
8787
Condition.EVERY_EVENT,
8888
Condition.EVENT_CREATED_BY_DETECTOR,
8989
Condition.EVENT_SEEN_COUNT,

tests/sentry/workflow_engine/endpoints/test_organization_data_condition_index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def setUp(self):
1919
"sentry.workflow_engine.registry.condition_handler_registry",
2020
new=self.registry,
2121
)
22-
self.registry_patcher.__enter__()
22+
self.registry_patcher.start()
2323

2424
@self.registry.register(Condition.REAPPEARED_EVENT)
2525
@dataclass(frozen=True)
@@ -56,7 +56,7 @@ class TestIgnoredCondition(DataConditionHandler):
5656

5757
def tearDown(self) -> None:
5858
super().tearDown()
59-
self.registry_patcher.__exit__(None, None, None)
59+
self.registry_patcher.stop()
6060

6161

6262
@region_silo_test

0 commit comments

Comments
 (0)