From e2d6a03c65dd8c63ac424c9ec3cf8e6005c670f0 Mon Sep 17 00:00:00 2001 From: vedant7007 Date: Mon, 10 Aug 2026 00:04:36 +0530 Subject: [PATCH] fix: accept object completedTopics in saveProgress so progress persists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The controller required completedTopics to be an Array, but the frontend, the Zod validator (z.record), the Mongoose schema ({ type: Object }), the import util, and resetProgress all use an object/map — so every save hit !Array.isArray({...}) and returned 400, and progress was silently lost (kept only in localStorage). Validate it as a plain object instead. Fixes #1727 --- backend/controllers/userSheetProgressController.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/controllers/userSheetProgressController.js b/backend/controllers/userSheetProgressController.js index 3cdd267b..76c2bfc6 100644 --- a/backend/controllers/userSheetProgressController.js +++ b/backend/controllers/userSheetProgressController.js @@ -60,10 +60,15 @@ exports.saveProgress = async (req, res) => { }); } - if (completedTopics !== undefined && !Array.isArray(completedTopics)) { + if ( + completedTopics !== undefined && + (typeof completedTopics !== "object" || + completedTopics === null || + Array.isArray(completedTopics)) + ) { return res.status(400).json({ success: false, - error: "Invalid completedTopics field, must be an array", + error: "Invalid completedTopics field, must be an object", }); }