Skip to content

Commit d1e9d20

Browse files
authored
ref(workflow_engine): Remove DetectorType (#82111)
## Description Removes the `DetectorType` from the `workflow_engine.type` and adds comments to clarify how this type is defined and used.
1 parent 703c3f5 commit d1e9d20

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/sentry/workflow_engine/models/detector.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ class Detector(DefaultFieldsModel, OwnerModel, JSONConfigBase):
5555
on_delete=models.SET_NULL,
5656
)
5757

58-
# The type of detector that is being used, this is used to determine the class
59-
# to load for the detector
58+
# maps to registry (sentry.issues.grouptype.registry) entries for GroupType.slug in sentry.issues.grouptype.GroupType
6059
type = models.CharField(max_length=200)
6160

6261
# The user that created the detector
@@ -106,8 +105,14 @@ def get_audit_log_data(self) -> dict[str, Any]:
106105

107106
@receiver(pre_save, sender=Detector)
108107
def enforce_config_schema(sender, instance: Detector, **kwargs):
108+
"""
109+
Ensures the detector type is valid in the grouptype registry.
110+
This needs to be a signal because the grouptype registry's entries are not available at import time.
111+
"""
109112
group_type = instance.group_type
113+
110114
if not group_type:
111115
raise ValueError(f"No group type found with type {instance.type}")
116+
112117
config_schema = group_type.detector_config_schema
113118
instance.validate_config(config_schema)

src/sentry/workflow_engine/types.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from enum import IntEnum, StrEnum
3+
from enum import IntEnum
44
from typing import TYPE_CHECKING, Any, Generic, TypeVar
55

66
from sentry.types.group import PriorityLevel
@@ -44,8 +44,3 @@ class DataConditionHandler(Generic[T]):
4444
@staticmethod
4545
def evaluate_value(value: T, comparison: Any, condition: str) -> DataConditionResult:
4646
raise NotImplementedError
47-
48-
49-
class DetectorType(StrEnum):
50-
ERROR = "ErrorDetector"
51-
METRIC_ALERT_FIRE = "metric_alert_fire"

0 commit comments

Comments
 (0)