Skip to content

Commit

Permalink
fix(ui): cel validation (#2801)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl authored Dec 11, 2024
1 parent cfe54b0 commit bb35203
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,20 @@ export const AlertsRulesBuilder = ({
// check if the CEL is valid by comparing the parsed query with the original CEL
// remove spaces so that "a && b" is the same as "a&&b"
const celQuery = formatQuery(parsedCELRulesToQuery, "cel");
/*
SHAHAR: this is the old way of checking if the CEL is valid
I think its over complicated so let's just check if the query is "1 == 1" (which is parse error)
I'll leave the old code here for reference
const isValidCEL =
celQuery.replace(/\s+/g, "") === celRules.replace(/\s+/g, "") ||
celRules === "";
*/

// SHAHAR: new way of checking if the CEL is valid
const isValidCEL = celRules == "" || celQuery !== "1 == 1";
setIsValidCEL(isValidCEL);

// close the menu
setShowSuggestions(false);
if (isValidCEL) {
Expand Down Expand Up @@ -495,8 +505,8 @@ export const AlertsRulesBuilder = ({
operators: getOperators(id),
}))
: customFields
? customFields
: [];
? customFields
: [];

const onImportSQL = () => {
setImportSQLOpen(true);
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.31.5"
version = "0.31.6"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down

0 comments on commit bb35203

Please sign in to comment.