fix(uptime): Allow strings in config thresholds#104706
Conversation
6211ae2 to
311d266
Compare
311d266 to
53215e3
Compare
src/sentry/workflow_engine/endpoints/validators/base/detector.py
Outdated
Show resolved
Hide resolved
53215e3 to
5b3b5a7
Compare
5b3b5a7 to
55f6954
Compare
55f6954 to
29d1339
Compare
| elif ( | ||
| mode_in_request | ||
| and requested_mode != current_mode | ||
| and requested_mode != UptimeMonitorMode.MANUAL | ||
| and not is_superuser | ||
| ): | ||
| raise serializers.ValidationError({"mode": ["Only superusers can modify `mode`"]}) | ||
| else: | ||
| # On create, non-superusers can only set MANUAL mode | ||
| if "mode" in attrs and attrs["mode"] != UptimeMonitorMode.MANUAL and not is_superuser: | ||
| raise serializers.ValidationError({"mode": ["Only superusers can modify `mode`"]}) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
This was correct. Fixed now
saponifi3d
left a comment
There was a problem hiding this comment.
seems 👍 to me from the detector platform perspective; i'm not sure about the details involved so probably good to have dan give it the final +1.
| class UptimeDomainCheckFailureValidator(BaseDetectorTypeValidator): | ||
| enforce_single_datasource = True | ||
| data_sources = serializers.ListField(child=UptimeMonitorDataSourceValidator(), required=False) | ||
| config = UptimeDomainCheckFailureConfigValidator(required=False) # type: ignore[assignment] |
There was a problem hiding this comment.
any thoughts on how we might be able to have a similar abstraction enforced through the base detector? my guess is that most detectors will have the not great error handling for the json config field.
it'd also be cool if we updated the base detector to allow for this kind of override without having to add a lint exception. 🤔
anywho, no action needed for this pr, just curious to get your take.
Fixes [NEW-664: Fix setting failure threshold in uptime detector creation](https://linear.app/getsentry/issue/NEW-664/fix-setting-failure-threshold-in-uptime-detector-creation)
29d1339 to
7f3a110
Compare
Fixes NEW-664: Fix setting failure threshold in uptime detector creation
Adds a DRF validator for the config field, replacing the generic
JSONField. This addresses a few problemsThe DRF validator will handle coercing strings to numbers (for fields like
failureThresholdandrecoveryThreshold. Without the DRF validator the JSON Schema simply rejects numbers as strings, which is how our frontend forms send data.Previously validation errors of the config were reported under the
configkey. But since many fields on the frontend may map to the config, there's no simple way to display config errors on their associated fields. With the DRF serializer we're able to correctly report errors tied back to specific fields (see the updated tests)