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
- Expand the parent task first (`task-master expand --id=N`) to generate subtasks
- Verify subtask IDs with `task-master show N` and use an existing subtask ID
- 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
- Run expand-task on parents before referencing subtask IDs
- Inspect subtasks with task-master show N before status updates
- Regenerate subtask references after tasks.json regeneration
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
- Invalid iterations: ${iterations}. Must be a positive intege
- Invalid subtask ID format: ${subtaskId}. Expected format: pa
- Invalid subtask ID: ${subId}. Subtask ID must be a positive
- Cannot make a task a subtask of itself
- PARENT_TASK_NOT_FOUND
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/30a9bb4c0dc82fa4.
Report an issue: GitHub.