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) {