eyaltoledano/claude-task-master · error

INVALID_TASKS_FILE

INVALID_TASKS_FILE

Error message

No valid tasks found in ${tasksJsonPath}

What it means

In coreNextTaskAction, after readJSON loads the tasks file, the code checks that the parsed data exists and contains a `tasks` array (next-task.js:53-62). If the file is missing, empty, unparseable, or lacks the expected shape, it returns INVALID_TASKS_FILE. This distinguishes 'file exists but content is not a valid task list' from argument errors.

Source

Thrown at mcp-server/src/core/direct-functions/next-task.js:58

		};
	}

	// Define the action function to be executed on cache miss
	const coreNextTaskAction = async () => {
		try {
			// Enable silent mode to prevent console logs from interfering with JSON response
			enableSilentMode();

			log.info(`Finding next task from ${tasksJsonPath}`);

			// Read tasks data using the provided path
			const data = readJSON(tasksJsonPath, projectRoot, tag);
			if (!data || !data.tasks) {
				disableSilentMode(); // Disable before return
				return {
					success: false,
					error: {
						code: 'INVALID_TASKS_FILE',
						message: `No valid tasks found in ${tasksJsonPath}`
					}
				};
			}

			// Read the complexity report
			const complexityReport = readComplexityReport(reportPath);

			// Find the next task
			const nextTask = findNextTask(data.tasks, complexityReport);

			if (!nextTask) {
				log.info(
					'No eligible next task found. All tasks are either completed or have unsatisfied dependencies'
				);
				return {
					success: true,
					data: {

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Verify the file exists at the exact path in the error message (ls the path shown).
  2. If the project has no tasks yet, run the parse-prd tool on your PRD to generate tasks.json first.
  3. Validate the JSON: it must be an object with a `tasks` array (e.g. `{"tasks":[{"id":1,...}]}`). Fix or regenerate it.
  4. If using tags, confirm the requested tag's tasks.json exists — the path may include a tag-specific file you did not initialize.

Example fix

// before
nextTaskDirect({ tasksJsonPath: '/proj/prd.txt' }, log);

// after
const tasksPath = '/proj/.taskmaster/tasks/tasks.json';
const raw = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
if (!Array.isArray(raw.tasks)) throw new Error('invalid tasks.json');
nextTaskDirect({ tasksJsonPath: tasksPath }, log);
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function tasksFileIsValid(p) {
  if (!fs.existsSync(p)) return false;
  try {
    const data = JSON.parse(fs.readFileSync(p, 'utf8'));
    return Array.isArray(data.tasks);
  } catch {
    return false;
  }
}
// call nextTaskDirect only if tasksFileIsValid(tasksJsonPath)

Type guard

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

Try / catch

const result = await nextTaskDirect({ tasksJsonPath }, log);
if (!result.success && result.error?.code === 'INVALID_TASKS_FILE') {
  // regenerate tasks.json via parse_prd before retrying
}

Prevention

When it happens

Trigger: tasksJsonPath points to a nonexistent file (readJSON returns null), the file contains invalid JSON, or the JSON is valid but has no top-level `tasks` property (e.g. `{"tasks": []}` missing, wrong schema, or an empty/newly-initialized project).

Common situations: Running next_task before ever running parse-prd (no tasks.json yet); pointing tasksJsonPath at the PRD file instead of tasks.json; a tag context whose tasks.json was deleted or never created; hand-edited tasks.json that broke the schema.

Related errors


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