mirror of
https://github.com/eyaltoledano/claude-task-master.git
synced 2026-01-30 06:12:05 +00:00
fix: validate AI task response before spreading object
Move validation check before object spread to properly catch null/malformed task responses. Previously crashed with "Cannot read properties of null" instead of the intended "Received invalid task object from AI" error.
This commit is contained in:
@@ -422,17 +422,17 @@ async function updateTaskById(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Full update mode: Use structured data directly
|
// Full update mode: Use structured data directly
|
||||||
const updatedTask = {
|
const aiTask = aiServiceResponse.mainResult?.task;
|
||||||
...aiServiceResponse.mainResult.task,
|
if (!aiTask || typeof aiTask !== 'object')
|
||||||
dependencies: aiServiceResponse.mainResult.task.dependencies ?? [],
|
|
||||||
priority: aiServiceResponse.mainResult.task.priority ?? null,
|
|
||||||
details: aiServiceResponse.mainResult.task.details ?? null,
|
|
||||||
testStrategy: aiServiceResponse.mainResult.task.testStrategy ?? null
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Task Validation/Correction (Keep existing logic) ---
|
|
||||||
if (!updatedTask || typeof updatedTask !== 'object')
|
|
||||||
throw new Error('Received invalid task object from AI.');
|
throw new Error('Received invalid task object from AI.');
|
||||||
|
|
||||||
|
const updatedTask = {
|
||||||
|
...aiTask,
|
||||||
|
dependencies: aiTask.dependencies ?? [],
|
||||||
|
priority: aiTask.priority ?? null,
|
||||||
|
details: aiTask.details ?? null,
|
||||||
|
testStrategy: aiTask.testStrategy ?? null
|
||||||
|
};
|
||||||
if (!updatedTask.title || !updatedTask.description)
|
if (!updatedTask.title || !updatedTask.description)
|
||||||
throw new Error('Updated task missing required fields.');
|
throw new Error('Updated task missing required fields.');
|
||||||
// Preserve ID if AI changed it
|
// Preserve ID if AI changed it
|
||||||
|
|||||||
Reference in New Issue
Block a user