From: cloudchamb3r Date: Tue, 8 Oct 2024 17:27:05 +0000 (+0900) Subject: Add null check for responseData.invalidTopics (#32212) X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2e12343fc4ca96a215d6820c4467b619eaa5cbe9;p=gitea.git Add null check for responseData.invalidTopics (#32212) Screenshot 2024-10-08 at 10 49 10 AM `responseData.invalidTopics` can be null but it wasn't handled. --- diff --git a/web_src/js/features/repo-home.ts b/web_src/js/features/repo-home.ts index f3e39ddb3c..ed1415d286 100644 --- a/web_src/js/features/repo-home.ts +++ b/web_src/js/features/repo-home.ts @@ -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()) {