diff --git a/public/components/event_analytics/explorer/query_assist/__tests__/input.test.tsx b/public/components/event_analytics/explorer/query_assist/__tests__/input.test.tsx index 7ced9cd288..1a95a5e379 100644 --- a/public/components/event_analytics/explorer/query_assist/__tests__/input.test.tsx +++ b/public/components/event_analytics/explorer/query_assist/__tests__/input.test.tsx @@ -85,7 +85,7 @@ describe(' spec', () => { ); }); - it('should not call summarize if disabled', async () => { + it('should call add error toast if summarize is disabled', async () => { coreRefs.summarizeEnabled = false; httpMock.post.mockRejectedValueOnce({ body: { statusCode: 429 } }); @@ -98,6 +98,13 @@ describe(' spec', () => { body: '{"question":"test-input","index":"selected-test-index"}', }); expect(httpMock.post).not.toBeCalledWith(QUERY_ASSIST_API.SUMMARIZE, expect.anything()); + expect(coreRefs.toasts?.addError).toBeCalledWith( + { + message: 'Request is throttled. Try again later or contact your administrator', + statusCode: 429, + }, + { title: 'Failed to generate results' } + ); }); it('should call summarize for generate and run errors', async () => { diff --git a/public/components/event_analytics/explorer/query_assist/input.tsx b/public/components/event_analytics/explorer/query_assist/input.tsx index e777943471..d5285d2986 100644 --- a/public/components/event_analytics/explorer/query_assist/input.tsx +++ b/public/components/event_analytics/explorer/query_assist/input.tsx @@ -251,7 +251,13 @@ export const QueryAssistInput: React.FC = (props) => { await props.handleTimePickerChange([QUERY_ASSIST_START_TIME, 'now']); await props.handleTimeRangePickerRefresh(undefined, true); } catch (error) { - generateSummary({ isError: true, response: JSON.stringify((error as ResponseError).body) }); + if (coreRefs.summarizeEnabled) { + generateSummary({ isError: true, response: JSON.stringify((error as ResponseError).body) }); + } else { + coreRefs.toasts?.addError(formatError(error as ResponseError), { + title: 'Failed to generate results', + }); + } } finally { setGeneratingOrRunning(false); }