Skip to content

Commit c827797

Browse files
authored
fix(aci): prevent invalid custom resolve thresholds (#104561)
Fixed resolution validation so that we compare against the medium threshold number if it exists, and the high threshold if not. Previously we were only checking against the high threshold. New: <img width="723" height="395" alt="Screenshot 2025-12-08 at 3 20 00 PM" src="https://github.com/user-attachments/assets/ea8c4382-22b4-4822-95b0-838a3d1dcd74" /> Also fixed a bug where the medium threshold direction was not changing when the high direction was changed by adding a `key` to the DirectionField to force a rerender (lmk if there are better solutions) Bug: <img width="519" height="162" alt="Screenshot 2025-12-08 at 3 23 49 PM" src="https://github.com/user-attachments/assets/66c6b4e4-c855-47fd-8ad1-9ac5c99ab0d4" />
1 parent 895ad88 commit c827797

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

static/app/views/detectors/components/forms/metric/metric.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,13 @@ function PriorityRow({
255255
/>
256256
) : (
257257
<DirectionField
258+
key={conditionType}
258259
aria-label={t('Threshold direction')}
259260
name="conditionTypeDisplay"
260261
hideLabel
261262
inline
262263
flexibleControlStateSize
263264
choices={conditionChoices}
264-
value={conditionType}
265265
defaultValue={conditionType}
266266
disabled
267267
/>

static/app/views/detectors/components/forms/metric/resolveSection.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@ function validateResolutionThreshold({
3131
form: MetricDetectorFormData;
3232
id: string;
3333
}): Array<[string, string]> {
34-
const {conditionType, highThreshold, detectionType, resolutionStrategy} = form;
35-
if (!conditionType || detectionType !== 'static' || resolutionStrategy !== 'custom') {
34+
const {
35+
conditionType,
36+
highThreshold,
37+
mediumThreshold,
38+
detectionType,
39+
resolutionStrategy,
40+
} = form;
41+
if (
42+
!conditionType ||
43+
(detectionType !== 'static' && detectionType !== 'percent') ||
44+
resolutionStrategy !== 'custom'
45+
) {
3646
return [];
3747
}
3848

3949
const resolutionNum = Number(form.resolutionValue);
40-
const conditionNum = Number(highThreshold);
50+
const conditionNum = Number(mediumThreshold || highThreshold);
4151

4252
if (
4353
Number.isFinite(resolutionNum) &&

0 commit comments

Comments
 (0)