From 556f1bf6a015db7c83c1dde719734f6d5de28787 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 02:08:50 +0530 Subject: [PATCH] update order of validation; catch exceptions in semver check (#1212) (#1214) (cherry picked from commit b350af5d97b0bed52184103be55aad969cd51886) Signed-off-by: Amardeepsingh Siglani Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- public/utils/helpers.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/utils/helpers.tsx b/public/utils/helpers.tsx index 97423a5c..c326eb56 100644 --- a/public/utils/helpers.tsx +++ b/public/utils/helpers.tsx @@ -650,12 +650,18 @@ export function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) { } export function dataSourceFilterFn(dataSource: SavedObject) { - const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ''; - const installedPlugins = dataSource?.attributes?.installedPlugins || []; - return ( - semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) && - pluginManifest.requiredOSDataSourcePlugins.every((plugin) => installedPlugins.includes(plugin)) - ); + try { + const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ''; + const installedPlugins = dataSource?.attributes?.installedPlugins || []; + return ( + pluginManifest.requiredOSDataSourcePlugins.every((plugin) => + installedPlugins.includes(plugin) + ) && semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) + ); + } catch (error: any) { + // Filter out invalid data source + return false; + } } export function getSeverityText(severity: string) {