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

Improve error handling when setting up and reading a new integration #2387

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
23 changes: 18 additions & 5 deletions server/adaptors/integrations/repository/integration_reader.ts
Original file line number Diff line number Diff line change
@@ -223,11 +223,24 @@ export class IntegrationReader {

switch (asset.type) {
case 'savedObjectBundle':
resultValue.push({
type: 'savedObjectBundle',
workflows: asset.workflows,
data: JSON.parse(serializedResult.value.data),
});
// Attempt to parse and process the integration data
try {
// Construct and push a savedObjectBundle with workflows and parsed data
resultValue.push({
type: 'savedObjectBundle',
workflows: asset.workflows,
data: JSON.parse(serializedResult.value.data),
});
} catch {
// Return error response if JSON parsing fails
return {
ok: false,
error: new Error(
`While parsing integration data for \`${serializedResult.value.name}\`:\n` +
'The data field is not valid JSON.'
),
};
}
break;
case 'query':
resultValue.push({
7 changes: 6 additions & 1 deletion server/adaptors/integrations/repository/utils.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,12 @@ export async function deepCheck(reader: IntegrationReader): Promise<Result<Integ

// Deep checks not included in default config validation
const assets = await reader.getAssets();
if (!assets.ok || assets.value.length === 0) {
// Check if there was an error retrieving assets
if (!assets.ok) {
return { ok: false, error: assets.error };
}
// Validate that at least one asset exists for the integration
if (assets.value.length === 0) {
return { ok: false, error: new Error('An integration must have at least one asset') };
}


Unchanged files with check annotations Beta

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

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'dataSourcePluggables'. Either include it or remove the dependency array
const { ui } =
currentPluggable?.getComponentSetForVariation(
'languages',
timestampField,
startTimeRange,
endTimeRange,
}: any = historyFromRedirection.location.state;

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

GitHub Actions / Lint

Unexpected any. Specify a different type
batch(() => {
if (datasourceName && datasourceType) {
dispatch(
setEndTime(endTimeRange);
}
});
}, []);

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

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 = () => {
setRefresh({});
});
}
}, []);

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

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 359 in public/components/event_analytics/explorer/explorer.tsx

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, {
callbackInApp(() => prepareAvailability());
}
}
}, [appBasedRef.current]);

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

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 (
) {
setSelectedContentTab(TAB_CHART_ID);
}
}, []);

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

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 490 in public/components/event_analytics/explorer/explorer.tsx

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) {
return hits;
}
return 0;
}, [countDistribution?.data]);

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

GitHub Actions / Lint

React Hook useMemo has missing dependencies: 'isLiveTailOn' and 'liveHits'. Either include them or remove the dependency array
const showTimeBasedComponents =
(isDefaultDataSourceType || appLogEvents) &&
)}
</div>
);
}, [

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

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,