From 9c1ad069ca80c6b5176b0468991bb80ddf422d56 Mon Sep 17 00:00:00 2001 From: Tamcodes4 Date: Sun, 28 Jun 2026 13:00:12 +0530 Subject: [PATCH] fix: guard against malformed/non-array history data in fetchUserInfo --- scripts/fetch-user-info.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/fetch-user-info.js b/scripts/fetch-user-info.js index df905505..fb0431de 100644 --- a/scripts/fetch-user-info.js +++ b/scripts/fetch-user-info.js @@ -29,7 +29,7 @@ async function fetchUserInfo(username) { // Auto-Migration Check & Routing if (Array.isArray(data)) { history = data; - } else { + } else if (data && typeof data === "object") { // Safe object destructuring for the new profile structure history = data.history || []; badges = data.badges || []; @@ -69,6 +69,8 @@ async function fetchUserInfo(username) { await Promise.allSettled([livePromise]); // Ensure history is sorted chronologically + // Guard against a corrupted history file (e.g. non-array `history` field) + history = Array.isArray(history) ? history : []; history.sort((a, b) => new Date(a.date) - new Date(b.date)); return {