From 56a80a1631bcfcdab9181f21f071ead527e68ff4 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:19:09 -0700 Subject: [PATCH] change order of validation and add try catch in semver check (#297) (#299) (cherry picked from commit 71411b402c01abe56fd5709543302941ddba3857) Signed-off-by: Joanne Wang Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- public/pages/Main/Main.tsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index c2cb4213..95d1ebb3 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -169,12 +169,22 @@ export default class Main extends Component { }; 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) { + // Filter out invalid data source + return false; + } }; getServices(http: HttpSetup) {