From 1c88c63739251aa372f83ac51b1e1eb6439bb39e Mon Sep 17 00:00:00 2001 From: Jay Kumar <70096901+35C4n0r@users.noreply.github.com> Date: Sun, 1 Dec 2024 13:17:53 +0530 Subject: [PATCH] fix: fix sql to cel conversion (#2662) Co-authored-by: Tal --- keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx b/keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx index 707df735d..2490708e1 100644 --- a/keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx +++ b/keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx @@ -505,6 +505,10 @@ export const AlertsRulesBuilder = ({ const convertSQLToCEL = (sql: string): string | null => { try { const query = parseSQL(sql); + // Validate the parsed query + if (!query || !query.rules || query.rules.length === 0) { + throw new Error("Invalid SQL query: No rules generated."); + } const formattedCel = formatQuery(query, "cel"); return formatQuery(parseCEL(formattedCel), "cel"); } catch (error) {