From 6900233c5aaa2d1a49f495e9f9a060796757a91e Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 17 May 2024 15:30:48 +0100 Subject: [PATCH] fix: Remove null or duplicate app entries from suggest_app_for_fsentry() --- packages/backend/src/helpers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/helpers.js b/packages/backend/src/helpers.js index d102309e..e2b80964 100644 --- a/packages/backend/src/helpers.js +++ b/packages/backend/src/helpers.js @@ -1770,7 +1770,15 @@ async function suggest_app_for_fsentry(fsentry, options){ monitor.end(); // return list - return suggested_apps; + return suggested_apps.filter((suggested_app, pos, self) => { + // Remove any null values caused by calling `get_app()` for apps that don't exist. + // This happens on self-host because we don't include `code`, among others. + if (!suggested_app) + return false; + + // Remove any duplicate entries + return self.indexOf(suggested_app) === pos; + }); } function build_item_object(item){