From 4815c4aeae41b72f5f891f4c5971dc8c7731de27 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 9 Oct 2024 09:18:29 +0800 Subject: [PATCH] Add null check for responseData.invalidTopics (#32212) (#32217) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport #32212 by @cloudchamb3r Screenshot 2024-10-08 at 10 49 10 AM `responseData.invalidTopics` can be null but it wasn't handled. Co-authored-by: cloudchamb3r --- web_src/js/features/repo-home.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/repo-home.js b/web_src/js/features/repo-home.js index 6a5bce8268054..3031432c933c1 100644 --- a/web_src/js/features/repo-home.js +++ b/web_src/js/features/repo-home.js @@ -60,7 +60,7 @@ export function initRepoTopicBar() { // how to test: input topic like " invalid topic " (with spaces), and select it from the list, then "Save" const responseData = await response.json(); lastErrorToast = showErrorToast(responseData.message, {duration: 5000}); - if (responseData.invalidTopics.length > 0) { + if (responseData.invalidTopics && responseData.invalidTopics.length > 0) { const {invalidTopics} = responseData; const topicLabels = queryElemChildren(topicDropdown, 'a.ui.label'); for (const [index, value] of topics.split(',').entries()) {