eyaltoledano/claude-task-master · error
Invalid tasks data in ${tasksPath}
Error message
Invalid tasks data in ${tasksPath} What it means
expandAllTasks() reads the tasks file with readJSON() and requires the result to contain a tasks property. A null result (unreadable/invalid JSON) or an object without tasks means there is nothing to expand, so it throws with the file path in the message.
Source
Thrown at scripts/modules/task-manager/expand-all-tasks.js:88
});
let loadingIndicator = null;
let expandedCount = 0;
let failedCount = 0;
let tasksToExpandCount = 0;
const allTelemetryData = []; // Still collect individual data first
if (!isMCPCall && outputFormat === 'text') {
loadingIndicator = startLoadingIndicator(
'Analyzing tasks for expansion...'
);
}
try {
logger.info(`Reading tasks from ${tasksPath}`);
const data = readJSON(tasksPath, projectRoot, tag);
if (!data || !data.tasks) {
throw new Error(`Invalid tasks data in ${tasksPath}`);
}
// --- Restore Original Filtering Logic ---
const tasksToExpand = data.tasks.filter(
(task) =>
(task.status === 'pending' || task.status === 'in-progress') && // Include 'in-progress'
(!task.subtasks || task.subtasks.length === 0 || force) // Check subtasks/force here
);
tasksToExpandCount = tasksToExpand.length; // Get the count from the filtered array
logger.info(`Found ${tasksToExpandCount} tasks eligible for expansion.`);
// --- End Restored Filtering Logic ---
if (loadingIndicator) {
stopLoadingIndicator(loadingIndicator, 'Analysis complete.');
}
if (tasksToExpandCount === 0) {
logger.info('No tasks eligible for expansion.');View on GitHub (pinned to c0c98d367c)
Solutions
- Verify the tasks file exists at the reported path and is valid JSON with a top-level tasks array.
- Run `task-master models --setup` no — instead re-generate the file via `task-master init` or `parse-prd` if it is missing.
- Confirm the correct tag is active (task-master use-tag) so readJSON resolves the right file.
Example fix
// before
{ "projectName": "app" } // no tasks key
// after
{ "projectName": "app", "tasks": [ { "id": 1, "title": "...", "description": "...", "status": "pending" } ] } Defensive patterns
Strategy: type-guard
Validate before calling
const fs = require('fs');
const raw = fs.readFileSync(tasksPath, 'utf8');
const data = JSON.parse(raw);
if (!data || !Array.isArray(data.tasks)) throw new Error(`${tasksPath} must contain a tasks array`); Type guard
function isTasksData(v) {
return !!v && typeof v === 'object' && Array.isArray(v.tasks);
} Try / catch
try {
await expandAllTasks(context);
} catch (err) {
if (err.message.startsWith('Invalid tasks data in')) {
console.error(`Fix or regenerate the tasks file at ${tasksPath}.`);
} else throw err;
} Prevention
- Validate tasks.json (JSON schema) after manual edits or merges.
- Confirm the active tag's tasks file exists before expansion.
- Never pass non-tasks JSON files as tasksPath.
When it happens
Trigger: readJSON(tasksPath, projectRoot, tag) returns null because the file does not exist or contains invalid JSON, or returns a JSON object lacking a tasks key (e.g. a complexity report or config file passed as tasksPath).
Common situations: Tasks file deleted or moved; syntax error introduced by manual editing; wrong tag resolution pointing to a nonexistent per-tag file; passing --file with the wrong document.
Related errors
- Invalid tasks data in ${tasksPath}
- No tasks found in the tasks file
- No valid tasks found in ${tasksPath}
- MFA_VERIFICATION_FAILED
- Failed to initialize services: ${(error as Error).message}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/e917d0548710a29a.
Report an issue: GitHub.