Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(log explorer): show PPL errors in toasts correctly #2154

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
return explorerSearchMeta.datasources?.[0]?.type
? dataSourcePluggables[explorerSearchMeta?.datasources[0]?.type]
: dataSourcePluggables.DEFAULT_INDEX_PATTERNS;
}, [explorerSearchMeta.datasources]);

Check warning on line 211 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'dataSourcePluggables'. Either include it or remove the dependency array
const { ui } =
currentPluggable?.getComponentSetForVariation(
'languages',
Expand Down Expand Up @@ -276,7 +276,7 @@
queryToRun,
startTimeRange,
endTimeRange,
}: any = historyFromRedirection.location.state;

Check warning on line 279 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
batch(() => {
if (datasourceName && datasourceType) {
dispatch(
Expand Down Expand Up @@ -317,7 +317,7 @@
setEndTime(endTimeRange);
}
});
}, []);

Check warning on line 320 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'dispatch', 'historyFromRedirection.location.state', 'setEndTime', 'setStartTime', and 'tabId'. Either include them or remove the dependency array. If 'setStartTime' changes too often, find the parent component that defines it and wrap that definition in useCallback

useEffect(() => {
const handleSetBrowserTabFocus = () => {
Expand All @@ -344,10 +344,10 @@
setRefresh({});
});
}
}, []);

Check warning on line 347 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'http'. Either include it or remove the dependency array

const getErrorHandler = (title: string) => {
return (error: any) => {

Check warning on line 350 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (coreRefs.summarizeEnabled) return;
const formattedError = formatError(error.name, error.message, error.body.message);
notifications.toasts.addError(formattedError, {
Expand Down Expand Up @@ -462,7 +462,7 @@
callbackInApp(() => prepareAvailability());
}
}
}, [appBasedRef.current]);

Check warning on line 465 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'callback', 'callbackInApp', and 'prepareAvailability'. Either include them or remove the dependency array. Mutable values like 'appBasedRef.current' aren't valid dependencies because mutating them doesn't re-render the component

useEffect(() => {
if (
Expand All @@ -471,14 +471,14 @@
) {
setSelectedContentTab(TAB_CHART_ID);
}
}, []);

Check warning on line 474 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'routerContext'. Either include it or remove the dependency array

useEffect(() => {
if (savedObjectId && !isObjectIdUpdatedFromSave.current) {
updateTabData(savedObjectId);
isObjectIdUpdatedFromSave.current = false;
}
}, [savedObjectId]);

Check warning on line 481 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'updateTabData'. Either include it or remove the dependency array

const handleTimePickerChange = async (timeRange: string[]) => {
if (appLogEvents) {
Expand Down Expand Up @@ -565,7 +565,7 @@
return hits;
}
return 0;
}, [countDistribution?.data]);

Check warning on line 568 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has missing dependencies: 'isLiveTailOn' and 'liveHits'. Either include them or remove the dependency array

const showTimeBasedComponents =
(isDefaultDataSourceType || appLogEvents) &&
Expand Down Expand Up @@ -694,7 +694,7 @@
)}
</div>
);
}, [

Check warning on line 697 in public/components/event_analytics/explorer/explorer.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has missing dependencies: 'dispatch', 'endTime', 'explorerSearchMeta?.datasources', 'getCountVisualizations', 'getErrorHandler', 'getPatterns', 'getTimeChartRange', 'handleTimeRangePickerRefresh', 'http', 'liveTimestamp', 'pplService', 'requestParams', 'showTimeBasedComponents', 'startTime', 'tabId', 'timeIntervalOptions', and 'totalHits'. Either include them or remove the dependency array. Mutable values like 'isLiveTailOnRef.current' aren't valid dependencies because mutating them doesn't re-render the component
isPanelTextFieldInvalid,
explorerData,
explorerFields,
Expand Down Expand Up @@ -811,8 +811,9 @@
if (availability !== true) {
await updateQueryInStore(searchedQuery);
}
await fetchData(undefined, undefined, setSummaryStatus);
setEventsLoading(false);
await fetchData(undefined, undefined, setSummaryStatus).finally(() => {
setEventsLoading(false);
});
};

const handleQueryChange = async (newQuery: string) => setTempQuery(newQuery);
Expand Down
104 changes: 49 additions & 55 deletions public/components/event_analytics/explorer/query_assist/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
EuiSmallButton,
EuiComboBoxOptionOption,
EuiCompressedFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiInputPopover,
EuiListGroup,
Expand Down Expand Up @@ -325,62 +323,58 @@ export const QueryAssistInput: React.FC<React.PropsWithChildren<Props>> = (props

return (
<>
<EuiFlexGroup gutterSize="none" alignItems="center" justifyContent="center">
<EuiFlexItem grow={false}>
<EuiIcon
className="euiFieldText"
style={{ padding: 8 }}
size="original"
type={chatLogo}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiInputPopover
input={
<EuiCompressedFieldText
inputRef={inputRef}
placeholder="Ask me a question"
disabled={loading}
value={props.nlqInput}
onChange={(e) => {
props.setNlqInput(e.target.value);
dismissCallOut();
}}
onKeyDown={(e) => {
// listen to enter key manually. the cursor jumps to CodeEditor with EuiForm's onSubmit
if (e.key === 'Enter') runAndSummarize();
}}
fullWidth
onFocus={() => {
props.setNeedsUpdate(false);
props.setLastFocusedInput('nlq_input');
if (props.nlqInput.length === 0) setIsPopoverOpen(true);
}}
<EuiInputPopover
input={
<EuiCompressedFieldText
inputRef={inputRef}
placeholder="Ask me a question"
disabled={loading}
value={props.nlqInput}
onChange={(e) => {
props.setNlqInput(e.target.value);
dismissCallOut();
}}
prepend={
<EuiIcon
className="euiFieldText"
style={{ padding: 8 }}
size="original"
type={chatLogo}
/>
}
disableFocusTrap
fullWidth={true}
isOpen={isPopoverOpen}
closePopover={() => {
setIsPopoverOpen(false);
onKeyDown={(e) => {
// listen to enter key manually. the cursor jumps to CodeEditor with EuiForm's onSubmit
if (e.key === 'Enter') runAndSummarize();
}}
>
<EuiListGroup flush={true} bordered={false} wrapText={true} maxWidth={false}>
{HARDCODED_SUGGESTIONS[selectedIndex]?.map((question, i) => (
<EuiListGroupItem
key={i}
onClick={() => {
props.setNlqInput(question);
inputRef.current?.focus();
setIsPopoverOpen(false);
}}
label={question}
/>
))}
</EuiListGroup>
</EuiInputPopover>
</EuiFlexItem>
</EuiFlexGroup>
fullWidth
onFocus={() => {
props.setNeedsUpdate(false);
props.setLastFocusedInput('nlq_input');
if (props.nlqInput.length === 0) setIsPopoverOpen(true);
}}
/>
}
disableFocusTrap
fullWidth={true}
isOpen={isPopoverOpen}
closePopover={() => {
setIsPopoverOpen(false);
}}
>
<EuiListGroup flush={true} bordered={false} wrapText={true} maxWidth={false}>
{HARDCODED_SUGGESTIONS[selectedIndex]?.map((question, i) => (
<EuiListGroupItem
key={i}
onClick={() => {
props.setNlqInput(question);
inputRef.current?.focus();
setIsPopoverOpen(false);
}}
label={question}
/>
))}
</EuiListGroup>
</EuiInputPopover>
{props.callOut}
<EuiSpacer size="s" />
{props.children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useFetchEvents = ({ pplService, requestParams }: IFetchEventsParams
) => {
setIsEventsLoading(true);
return pplService
.fetch({ query, format }, errorHandler)
.fetch({ query, format }, undefined, errorHandler)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's regression from MDS PR, see description and 7b5cc9f commit message:

  • update fetch call to pass in data source id
    • data source id is always undefined because log explorer doesn't support multi-datasource. passing undefined fixes the parameters so UI shows PPL errors in toasts

.then((res: any) => handler(res))
.catch((err: any) => {
console.error(err);
Expand Down
Loading