diff --git a/.changeset/any-numeric-threshold.md b/.changeset/any-numeric-threshold.md new file mode 100644 index 00000000..e8de327a --- /dev/null +++ b/.changeset/any-numeric-threshold.md @@ -0,0 +1,7 @@ +--- +"@hyperdx/common-utils": patch +"@hyperdx/api": patch +"@hyperdx/app": patch +--- + +fix: allow any numeric value for alert thresholds diff --git a/packages/api/src/utils/__tests__/enhancedErrors.test.ts b/packages/api/src/utils/__tests__/enhancedErrors.test.ts index ca1389e6..68926007 100644 --- a/packages/api/src/utils/__tests__/enhancedErrors.test.ts +++ b/packages/api/src/utils/__tests__/enhancedErrors.test.ts @@ -155,7 +155,7 @@ describe('enhancedErrors', () => { source: 'tile', tileId: '507f1f77bcf86cd799439011', dashboardId: '507f1f77bcf86cd799439011', - threshold: -5, // Invalid: negative threshold + threshold: -5, interval: '99m', // Invalid: not a valid interval thresholdType: 'above', channel: { @@ -166,7 +166,7 @@ describe('enhancedErrors', () => { expect(response.status).toBe(400); expect(response.body.message).toEqual( - "Body validation failed: interval: Invalid enum value. Expected '1m' | '5m' | '15m' | '30m' | '1h' | '6h' | '12h' | '1d', received '99m'; threshold: Number must be greater than or equal to 0; Params validation failed: id: Invalid input", + "Body validation failed: interval: Invalid enum value. Expected '1m' | '5m' | '15m' | '30m' | '1h' | '6h' | '12h' | '1d', received '99m'; Params validation failed: id: Invalid input", ); }); }); diff --git a/packages/api/src/utils/zod.ts b/packages/api/src/utils/zod.ts index bccb1081..6fa96b8a 100644 --- a/packages/api/src/utils/zod.ts +++ b/packages/api/src/utils/zod.ts @@ -412,7 +412,7 @@ export const alertSchema = z interval: z.enum(['1m', '5m', '15m', '30m', '1h', '6h', '12h', '1d']), scheduleOffsetMinutes: z.number().int().min(0).max(1439).optional(), scheduleStartAt: scheduleStartAtSchema, - threshold: z.number().min(0), + threshold: z.number(), thresholdType: z.nativeEnum(AlertThresholdType), source: z.nativeEnum(AlertSource).default(AlertSource.SAVED_SEARCH), name: z.string().min(1).max(512).nullish(), diff --git a/packages/app/src/DBSearchPageAlertModal.tsx b/packages/app/src/DBSearchPageAlertModal.tsx index d1f0e8b7..51247e8d 100644 --- a/packages/app/src/DBSearchPageAlertModal.tsx +++ b/packages/app/src/DBSearchPageAlertModal.tsx @@ -62,7 +62,7 @@ import { optionsToSelectData } from './utils'; const SavedSearchAlertFormSchema = z .object({ interval: AlertIntervalSchema, - threshold: z.number().int().min(1), + threshold: z.number(), scheduleOffsetMinutes: z.number().int().min(0).default(0), scheduleStartAt: scheduleStartAtSchema, thresholdType: z.nativeEnum(AlertThresholdType), @@ -170,7 +170,6 @@ const AlertForm = ({ control={control} /> { ); }; -const MINIMUM_THRESHOLD_VALUE = 0.0000000001; // to make alert input > 0 - type SeriesItem = NonNullable< SavedChartConfigWithSelectArray['select'] >[number]; @@ -1381,7 +1379,6 @@ export default function EditTimeChartForm({ control={control} />