eyaltoledano/claude-task-master · error
Invalid iterations: ${iterations}. Must be a positive intege
Error message
Invalid iterations: ${iterations}. Must be a positive integer. What it means
When the task ID contains a dot (subtask form like '1.2'), updateSingleTaskStatus parses the parent ID and looks it up in data.tasks; it throws if no task with that numeric parent ID exists. The subtask update cannot proceed without its parent.
Source
Thrown at apps/cli/src/commands/loop.command.ts:176
console.log(
chalk.yellow(
'Sandbox needs authentication. Starting interactive session...'
)
);
console.log(chalk.dim('Please complete auth, then Ctrl+C to continue.\n'));
const authResult = this.tmCore.loop.runInteractiveAuth();
if (!authResult.success) {
throw new Error(authResult.error || 'Interactive authentication failed');
}
console.log(chalk.green('✓ Auth complete\n'));
}
private validateIterations(iterations: string): void {
const parsed = Number(iterations);
if (!Number.isInteger(parsed) || parsed < 1) {
throw new Error(
`Invalid iterations: ${iterations}. Must be a positive integer.`
);
}
}
private createOutputCallbacks(): LoopOutputCallbacks {
return {
onIterationStart: (iteration: number, total: number) => {
console.log();
console.log(chalk.cyan(`━━━ Iteration ${iteration} of ${total} ━━━`));
},
onText: (text: string) => {
console.log(text);
},
onToolUse: (toolName: string) => {
console.log(chalk.dim(` → ${toolName}`));
},
onError: (message: string, severity?: 'warning' | 'error') => {View on GitHub (pinned to c0c98d367c)
Solutions
- Verify the parent task ID exists (`task-master list`) and correct the ID
- Ensure the same tag context is used for viewing and updating (use --tag)
- Regenerate/refresh task data if the parent was removed (parse-prd / regenerate)
Example fix
// before
await setTaskStatus(tasksPath, '12.3', 'done'); // task 12 doesn't exist
// after
const tasks = await getTasks(tasksPath);
if (!tasks.some(t => t.id === 12)) throw new Error('Task 12 missing');
await setTaskStatus(tasksPath, '12.3', 'done'); Defensive patterns
Strategy: validation
Validate before calling
const [parentStr] = taskId.split('.');
const parentId = parseInt(parentStr, 10);
const tasks = JSON.parse(fs.readFileSync(tasksPath, 'utf8')).tasks;
if (!tasks.some(t => t.id === parentId)) {
throw new Error(`Parent task ${parentId} not found; run 'task-master list' for valid IDs`);
} Try / catch
try {
await setTaskStatus(tasksPath, '7.1', 'done');
} catch (e) {
if (/Parent task \d+ not found/.test(e.message)) {
throw new Error('Stale subtask ID: refresh with task-master list / re-parse PRD');
}
throw e;
} Prevention
- Fetch fresh task IDs (task-master list) instead of hardcoding IDs in scripts
- Ensure the same --tag context for viewing and updating
- Re-verify IDs after any parse-prd/regenerate/prune operation
When it happens
Trigger: Calling setTaskStatus/updateSingleTaskStatus with an ID like '7.1' where task 7 doesn't exist in the (tag-filtered) data.tasks array — often because the tasks were viewed under a different tag or the parent was deleted/renumbered.
Common situations: Stale IDs after tasks were regenerated or pruned; querying a different tag context than the data was loaded with; typos in the parent portion of the subtask ID.
Related errors
- Invalid format: ${options.format}. Valid formats are: text,
- 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/c602ee23576fc0f9.
Report an issue: GitHub.