Skip to content

Commit 06e0744

Browse files
Fix: Cannot compile alerts query (#887)
* feat: upload checksum (#5) * Fix: Cannot compile alert query
1 parent 25fa23e commit 06e0744

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/components/config/validate.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { compileExpression } from '../../utils/expression-parser'
3434
import type { SymonConfig } from '../reporter'
3535
import { newPagerDuty } from '../notification/channel/pagerduty'
3636

37-
const HTTPMethods = [
37+
const HTTPMethods = new Set([
3838
'DELETE',
3939
'GET',
4040
'HEAD',
@@ -45,7 +45,7 @@ const HTTPMethods = [
4545
'PURGE',
4646
'LINK',
4747
'UNLINK',
48-
]
48+
])
4949

5050
const setInvalidResponse = (message: string): Validation => ({
5151
valid: false,
@@ -284,7 +284,9 @@ const isValidProbeAlert = (alert: ProbeAlert | string): boolean => {
284284
)
285285
}
286286

287-
return Boolean(compileExpression(alert.assertion))
287+
return Boolean(
288+
compileExpression(alert.assertion || (alert.query as string))
289+
)
288290
} catch {
289291
return false
290292
}
@@ -357,7 +359,7 @@ export const validateConfig = (configuration: Config): Validation => {
357359
return PROBE_REQUEST_INVALID_URL
358360
}
359361

360-
if (!HTTPMethods.includes(method?.toUpperCase() ?? 'GET'))
362+
if (!HTTPMethods.has(method?.toUpperCase() ?? 'GET'))
361363
return PROBE_REQUEST_INVALID_METHOD
362364
}
363365
}
@@ -446,7 +448,7 @@ function validateRedisConfig(redisConfig?: Redis[]) {
446448
host: Joi.alternatives()
447449
.try(Joi.string().hostname(), Joi.string().ip())
448450
.required(),
449-
port: Joi.number().min(0).max(65536).required(),
451+
port: Joi.number().min(0).max(65_536).required(),
450452
password: Joi.string(),
451453
username: Joi.string(),
452454
command: Joi.string(),

src/plugins/validate-response/checkers/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const responseChecker = (
5454
return true
5555
}
5656

57-
return queryExpression(res, alert.assertion)
57+
return queryExpression(res, alert.assertion || (alert.query as string))
5858
}
5959

6060
export default responseChecker

0 commit comments

Comments
 (0)