Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

fix: validate AI task response before spreading object

Ralph Khreish1d8d72315fae
diff --git a/scripts/modules/task-manager/update-task-by-id.js b/scripts/modules/task-manager/update-task-by-id.js
index b4616603..4049c268 100644
--- a/scripts/modules/task-manager/update-task-by-id.js
+++ b/scripts/modules/task-manager/update-task-by-id.js
@@ -422,17 +422,17 @@ async function updateTaskById(
}
// Full update mode: Use structured data directly
+ const aiTask = aiServiceResponse.mainResult?.task;
+ if (!aiTask || typeof aiTask !== 'object')
+ throw new Error('Received invalid task object from AI.');
+
const updatedTask = {
- ...aiServiceResponse.mainResult.task,
- dependencies: aiServiceResponse.mainResult.task.dependencies ?? [],
- priority: aiServiceResponse.mainResult.task.priority ?? null,
- details: aiServiceResponse.mainResult.task.details ?? null,
- testStrategy: aiServiceResponse.mainResult.task.testStrategy ?? null
+ ...aiTask,
+ dependencies: aiTask.dependencies ?? [],
+ priority: aiTask.priority ?? null,
+ details: aiTask.details ?? null,
+ testStrategy: aiTask.testStrategy ?? null
};
-
- // --- Task Validation/Correction (Keep existing logic) ---
- if (!updatedTask || typeof updatedTask !== 'object')
- throw new Error('Received invalid task object from AI.');
if (!updatedTask.title || !updatedTask.description)
throw new Error('Updated task missing required fields.');
// Preserve ID if AI changed it