eyaltoledano/claude-task-master · error

Invalid format: ${options.format}. Valid formats are: text,

Error message

Invalid format: ${options.format}. Valid formats are: text, json

What it means

For subtask IDs like '1.2', after finding the parent task, updateSingleTaskStatus checks that parentTask.subtasks exists and throws if the parent has none. This means the ID references a subtask under a parent that never had subtasks generated.

Source

Thrown at apps/cli/src/commands/next.command.ts:105

			displayError(error, { skipExit: true });
		} finally {
			// Always clean up resources, even on error
			await this.cleanup();
		}

		// Exit after cleanup completes
		if (hasError) {
			process.exit(1);
		}
	}

	/**
	 * Validate command options
	 */
	private validateOptions(options: NextCommandOptions): void {
		// Validate format
		if (options.format && !['text', 'json'].includes(options.format)) {
			throw new Error(
				`Invalid format: ${options.format}. Valid formats are: text, json`
			);
		}
	}

	/**
	 * Initialize TmCore
	 */
	private async initializeCore(projectRoot: string): Promise<void> {
		if (!this.tmCore) {
			const resolved = path.resolve(projectRoot);
			this.tmCore = await createTmCore({ projectPath: resolved });
		}
	}

	/**
	 * Get next task from tm-core
	 */

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Expand the parent task first (`task-master expand --id=N`) to generate subtasks
  2. Verify subtask IDs with `task-master show N` and use an existing subtask ID
  3. Set status on the parent task instead if subtasks are not needed

Example fix

// before
await setTaskStatus(tasksPath, '4.1', 'done'); // task 4 has no subtasks
// after
await expandTask(tasksPath, 4); // generate subtasks
await setTaskStatus(tasksPath, '4.1', 'done');
Defensive patterns

Strategy: validation

Validate before calling

const [parentStr, subStr] = taskId.split('.');
const parent = JSON.parse(fs.readFileSync(tasksPath, 'utf8')).tasks.find(t => t.id === parseInt(parentStr, 10));
if (!parent || !Array.isArray(parent.subtasks) || !parent.subtasks.some(s => s.id === parseInt(subStr, 10))) {
  throw new Error(`Subtask ${taskId} missing; run 'task-master expand --id=${parentStr}' first`);
}

Try / catch

try {
  await setTaskStatus(tasksPath, '4.1', 'done');
} catch (e) {
  if (e.message.includes('has no subtasks')) {
    throw new Error(`Task 4 has no subtasks; run: task-master expand --id=4`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling setTaskStatus with 'N.M' where task N exists but has an empty or undefined subtasks array, e.g. expand-task was never run on the parent or expansion produced zero subtasks.

Common situations: Attempting to status a subtask before running `task-master expand --id=N`; subtask IDs copied from an old tasks.json after regeneration cleared subtasks; assuming all parents have subtasks.

Related errors


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