Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from rest_framework.request import Request
from rest_framework.response import Response

from sentry import features
from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import cell_silo_endpoint
Expand All @@ -23,7 +22,6 @@
ValidationErrorResponse,
as_validation_errors,
)
from sentry.incidents.grouptype import MetricIssue
from sentry.models.project import Project
from sentry.workflow_engine.endpoints.organization_detector_index import get_detector_validator
from sentry.workflow_engine.endpoints.serializers.detector_serializer import (
Expand Down Expand Up @@ -75,23 +73,11 @@ def post(
"""
Create a Monitor for a project
"""
organization = project.organization

detector_type = request.data.get("type")
if not detector_type:
raise ValidationError({"type": ["This field is required."]})

# Restrict creating metric issue detectors by plan type.
# This is a coarse pre-check; the validator enforces the dataset-specific
# is_metric_subscription_allowed check after the dataset is validated.
if detector_type == MetricIssue.slug and not features.has(
"organizations:incidents", organization, actor=request.user
):
return Response(
{"detail": "Unable to process request, confirm payment options."},
status=status.HTTP_400_BAD_REQUEST,
)

validator = get_detector_validator(request, project, detector_type)
if not validator.is_valid():
return Response(as_validation_errors(validator), status=status.HTTP_400_BAD_REQUEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,6 @@ def test_incompatible_group_type(self) -> None:
)
assert response.data == {"type": ["Detector type not compatible with detectors"]}

def test_without_feature_flag(self) -> None:
with self.feature({"organizations:incidents": False}):
response = self.get_error_response(
self.organization.slug,
self.project.slug,
**self.valid_data,
status_code=400,
)
assert response.data == {
"detail": ErrorDetail(
string="Unable to process request, confirm payment options.", code="error"
)
}

def test_create_blocked_when_dataset_not_allowed(self) -> None:
"""
Creating a metric detector should be blocked when the org lacks
Expand Down
Loading