From 4e4d324bcfb12c35018bbd13fd23f9e022fdb039 Mon Sep 17 00:00:00 2001 From: Joanne Wang Date: Tue, 29 Oct 2024 17:00:24 -0700 Subject: [PATCH] change order of validation and all trycatch in semver check Signed-off-by: Joanne Wang --- public/utils/helpers.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/utils/helpers.js b/public/utils/helpers.js index f95f3b6fc..91d748666 100644 --- a/public/utils/helpers.js +++ b/public/utils/helpers.js @@ -172,12 +172,18 @@ export function getManageChannelsUrl() { } export function dataSourceFilterFn(dataSource) { - 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; + } } export function getSeverityText(severity) {