Skip to content

Commit 89fd984

Browse files
authored
chore(crons): Clean up MonitorCheckInValidator to stop accepting monitor config (#97788)
We no longer use this code - it was probably from when we accepted checkins via api. In the consumer, we pop `monitor_config` out of the attributes before we pass them in via data, so this is unused. Cleaning this up makes the work I'm doing with crons -> detectors easier
1 parent f998b41 commit 89fd984

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

src/sentry/monitors/validators.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -392,60 +392,8 @@ class MonitorCheckInValidator(serializers.Serializer):
392392
allow_null=True,
393393
help_text="Name of the environment.",
394394
)
395-
monitor_config = ConfigValidator(required=False)
396395
contexts = ContextsValidator(required=False, allow_null=True)
397396

398-
def validate(self, attrs):
399-
attrs = super().validate(attrs)
400-
401-
# Support specifying monitor configuration via a check-in
402-
#
403-
# NOTE: Most monitor attributes are contextual (project, slug, etc),
404-
# the monitor config is passed in via this checkin serializer's
405-
# monitor_config attribute.
406-
#
407-
# NOTE: We have already validated the monitor_config in the
408-
# ConfigValidator field, to keep things simple, we'll just stick
409-
# the initial_data back into the monitor validator
410-
monitor_config = self.initial_data.get("monitor_config")
411-
if monitor_config:
412-
project = self.context["project"]
413-
instance = {}
414-
monitor = self.context.get("monitor", None)
415-
if monitor:
416-
instance = {
417-
"name": monitor.name,
418-
"slug": monitor.slug,
419-
"status": monitor.status,
420-
"type": monitor.type,
421-
"config": monitor.config,
422-
"project": project,
423-
}
424-
425-
# Use context to complete the full monitor validator object
426-
monitor_validator = MonitorValidator(
427-
data={
428-
"type": "cron_job",
429-
"name": self.context["monitor_slug"],
430-
"slug": self.context["monitor_slug"],
431-
"project": project.slug,
432-
"config": monitor_config,
433-
},
434-
instance=instance,
435-
context={
436-
"organization": project.organization,
437-
"access": self.context["request"].access,
438-
},
439-
)
440-
monitor_validator.is_valid(raise_exception=True)
441-
442-
# Drop the `monitor_config` attribute favor in favor of the fully
443-
# validated monitor data
444-
attrs["monitor"] = monitor_validator.validated_data
445-
del attrs["monitor_config"]
446-
447-
return attrs
448-
449397

450398
class MonitorBulkEditValidator(MonitorValidator):
451399
ids = serializers.ListField(

0 commit comments

Comments
 (0)