eyaltoledano/claude-task-master · error

No valid tasks found in ${tasksPath}. The file may be corrup

Error message

No valid tasks found in ${tasksPath}. The file may be corrupted or have an invalid format.

What it means

readJSON succeeded but returned null/undefined or an object without a tasks array, so the file content is unusable. This guards against corrupted or structurally invalid tasks.json files.

Source

Thrown at scripts/modules/task-manager/update-subtask-by-id.js:135

			};
		}
		// Otherwise fall through to file-based logic below
		// --- End BRIDGE ---

		// For file storage, validate the subtask ID format (must contain a dot)
		if (!subtaskId.includes('.')) {
			throw new Error(
				`Invalid subtask ID format: ${subtaskId}. In solo mode, subtask ID must be in format "parentId.subtaskId" (e.g., "5.2").`
			);
		}

		if (!fs.existsSync(tasksPath)) {
			throw new Error(`Tasks file not found at path: ${tasksPath}`);
		}

		const data = readJSON(tasksPath, projectRoot, tag);
		if (!data || !data.tasks) {
			throw new Error(
				`No valid tasks found in ${tasksPath}. The file may be corrupted or have an invalid format.`
			);
		}

		const [parentIdStr, subtaskIdStr] = subtaskId.split('.');
		const parentId = parseInt(parentIdStr, 10);
		const subtaskIdNum = parseInt(subtaskIdStr, 10);

		if (
			Number.isNaN(parentId) ||
			parentId <= 0 ||
			Number.isNaN(subtaskIdNum) ||
			subtaskIdNum <= 0
		) {
			throw new Error(
				`Invalid subtask ID format: ${subtaskId}. Both parent ID and subtask ID must be positive integers.`
			);
		}

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Inspect tasks.json and fix or restore valid JSON with a top-level tasks array
  2. Restore from git: git checkout -- .taskmanager/tasks.json or a backup
  3. Rebuild via 'task-master generate' or re-run init if unrecoverable

Example fix

// before
// tasks.json: { "notes": [] }  (no tasks array)
// after
// tasks.json: { "tasks": [ { "id": 1, "title": "...", "status": "pending" } ] }
Defensive patterns

Strategy: validation

Validate before calling

const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
if (!data || !Array.isArray(data.tasks)) {
  throw new Error(`${tasksPath} has no tasks array`);
}

Type guard

function hasValidTasksData(v) {
  return v !== null && typeof v === 'object' && Array.isArray(v.tasks);
}

Try / catch

try {
  await updateSubtaskById(subtaskId, prompt, options);
} catch (err) {
  if (err.message.includes('No valid tasks found')) {
    console.error('Restore tasks.json from git or regenerate it');
  } else throw err;
}

Prevention

When it happens

Trigger: tasks.json containing invalid JSON, an empty object, or JSON without a top-level tasks array; partial writes truncating the file.

Common situations: Manual edits to tasks.json that broke the schema, merge conflicts resolved incorrectly, disk-full or interrupted writes, schema drift between task-master versions.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/3e0e0bce90876674. Report an issue: GitHub.