From 7d4438f3e83fac3ce09e5fa0c72cc8ddb105de69 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Wed, 11 Jan 2023 04:20:37 -0700 Subject: [PATCH] fix: print error when __CATEGORIES__ used and no categories set (#388) * Print error when categories are empty * lint fix --- src/views/QueryExplorer.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/views/QueryExplorer.vue b/src/views/QueryExplorer.vue index 931e53c2..ef351579 100644 --- a/src/views/QueryExplorer.vue +++ b/src/views/QueryExplorer.vue @@ -83,7 +83,12 @@ RETURN = sort_by_duration(merged_events); // replace magic string `__CATEGORIES__` in query text with latest category rule if (_.includes(query, '__CATEGORIES__')) { const categoryRules = useCategoryStore().classes_for_query; - // const classes_str = JSON.stringify(params.classes).replace(/\\\\/g, '\\'); + + if (useCategoryStore().classes_for_query.length === 0) { + this.error = '__CATEGORIES__ was used in query but no categories have been defined yet.'; + return; + } + query = query.replace('__CATEGORIES__', JSON.stringify(categoryRules)); }