diff --git a/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.test.ts b/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.test.ts index e40cc46a27..cd7f1ecc0d 100644 --- a/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.test.ts +++ b/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.test.ts @@ -26,16 +26,21 @@ describe("convertCelAstToQueryBuilderAst", () => { combinator: "and", rules: [ { - field: "field1", - operator: "=", - value: "value1", - id: expect.any(String), - }, - { - field: "field2", - operator: "!=", - value: "value2", - id: expect.any(String), + combinator: "and", + rules: [ + { + field: "field1", + operator: "=", + value: "value1", + id: expect.any(String), + }, + { + field: "field2", + operator: "!=", + value: "value2", + id: expect.any(String), + }, + ], }, ], }); @@ -169,9 +174,14 @@ describe("convertCelAstToQueryBuilderAst", () => { combinator: "and", rules: [ { - field: "field1", - operator: "null", - id: expect.any(String), + combinator: "and", + rules: [ + { + field: "field1", + operator: "null", + id: expect.any(String), + }, + ], }, ], }); @@ -201,10 +211,15 @@ describe("convertCelAstToQueryBuilderAst", () => { combinator: "and", rules: [ { - field: "field1.field2", - operator: queryBuilderOperator, - value: "testValue", - id: expect.any(String), + combinator: "and", + rules: [ + { + field: "field1.field2", + operator: queryBuilderOperator, + value: "testValue", + id: expect.any(String), + }, + ], }, ], }); @@ -227,9 +242,14 @@ describe("convertCelAstToQueryBuilderAst", () => { combinator: "and", rules: [ { - field: "field1.field2", - operator: "notNull", - id: expect.any(String), + combinator: "and", + rules: [ + { + field: "field1.field2", + operator: "notNull", + id: expect.any(String), + }, + ], }, ], }); @@ -253,10 +273,15 @@ describe("convertCelAstToQueryBuilderAst", () => { combinator: "and", rules: [ { - field: "field1", - operator: "notIn", - value: [1, 2, 3], - id: expect.any(String), + combinator: "and", + rules: [ + { + field: "field1", + operator: "notIn", + value: [1, 2, 3], + id: expect.any(String), + }, + ], }, ], }); @@ -286,10 +311,15 @@ describe("convertCelAstToQueryBuilderAst", () => { combinator: "and", rules: [ { - field: "field1", - operator: queryBuilderOperator, - value: "testValue", - id: expect.any(String), + combinator: "and", + rules: [ + { + field: "field1", + operator: queryBuilderOperator, + value: "testValue", + id: expect.any(String), + }, + ], }, ], }); diff --git a/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.ts b/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.ts index ae29961a19..74d930253e 100644 --- a/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.ts +++ b/keep-ui/app/(keep)/rules/CorrelationSidebar/convert-cel-ast-to-query-builder-ast/convert-cel-ast-to-query-builder-ast.function.ts @@ -174,7 +174,7 @@ export function visitCelAstNode(node: CelAst.Node): DefaultRuleGroupType { export function convertCelAstToQueryBuilderAst( node: CelAst.Node ): DefaultRuleGroupType { - const rulesGroup = visitCelAstNode(node); + let rulesGroup = visitCelAstNode(node); if (rulesGroup.combinator === "or") { // React Query Builder requires all rules to be within "and" combinator groups to function correctly. @@ -192,5 +192,12 @@ export function convertCelAstToQueryBuilderAst( }); } + if (rulesGroup.combinator == "and") { + rulesGroup = { + combinator: "and", + rules: [rulesGroup], + }; + } + return rulesGroup; }