File tree Expand file tree Collapse file tree
public/pages/CreateMonitor/containers/DefineMonitor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -348,8 +348,8 @@ class DefineMonitor extends Component {
348348 'Invalid input in data filter. Remove data filter or adjust filter '
349349 )
350350 : loadingResponse
351- ? renderEmptyMessage ( )
352- : previewContent ( ) }
351+ ? renderEmptyMessage ( )
352+ : previewContent ( ) }
353353 </ EuiAccordion >
354354 < EuiSpacer size = "m" />
355355 </ >
@@ -369,6 +369,24 @@ class DefineMonitor extends Component {
369369 const canExecute = searchType === SEARCH_TYPE . GRAPH && validDocLevelGraphQueries ( queries ) ;
370370 if ( ! canExecute ) return ;
371371 }
372+
373+ // Don't attempt to run a preview until the query is actually executable.
374+ // A freshly-opened monitor (e.g. reached via a direct deep-link to
375+ // #/create-monitor, which mounts CreateMonitor before the data source
376+ // resolves) has no index and no time field yet. Building a graph/query
377+ // request from that state yields a `range` clause with an empty field
378+ // name (`{ range: { "": {...} } }`), which the backend rejects with
379+ // "[bool] failed to parse field [filter]" and surfaces as a spurious
380+ // "Failed to run the query" toast. componentDidMount already gates the
381+ // initial run on these conditions; centralize the same guard here so the
382+ // componentDidUpdate aggregation/bucket branch can't bypass it.
383+ const isIndexBackedSearch =
384+ searchType === SEARCH_TYPE . GRAPH || searchType === SEARCH_TYPE . QUERY ;
385+ const hasIndices = Array . isArray ( values . index ) && values . index . length > 0 ;
386+ if ( isIndexBackedSearch && ( ! hasIndices || ( this . requiresTimeField ( ) && ! values . timeField ) ) ) {
387+ return ;
388+ }
389+
372390 this . setState ( { loadingResponse : true } ) ;
373391
374392 const formikSnapshot = _ . cloneDeep ( values ) ;
You can’t perform that action at this time.
0 commit comments