{"record":{"id":"c602ee23576fc0f9","repo":"eyaltoledano/claude-task-master","slug":"invalid-iterations-iterations-must-be-a-posit","errorCode":null,"errorMessage":"Invalid iterations: ${iterations}. Must be a positive integer.","messagePattern":"Invalid iterations: (.+?)\\. Must be a positive integer\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/cli/src/commands/loop.command.ts","lineNumber":176,"sourceCode":"\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t'Sandbox needs authentication. Starting interactive session...'\n\t\t\t)\n\t\t);\n\t\tconsole.log(chalk.dim('Please complete auth, then Ctrl+C to continue.\\n'));\n\n\t\tconst authResult = this.tmCore.loop.runInteractiveAuth();\n\t\tif (!authResult.success) {\n\t\t\tthrow new Error(authResult.error || 'Interactive authentication failed');\n\t\t}\n\t\tconsole.log(chalk.green('✓ Auth complete\\n'));\n\t}\n\n\tprivate validateIterations(iterations: string): void {\n\t\tconst parsed = Number(iterations);\n\t\tif (!Number.isInteger(parsed) || parsed < 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid iterations: ${iterations}. Must be a positive integer.`\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate createOutputCallbacks(): LoopOutputCallbacks {\n\t\treturn {\n\t\t\tonIterationStart: (iteration: number, total: number) => {\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.cyan(`━━━ Iteration ${iteration} of ${total} ━━━`));\n\t\t\t},\n\t\t\tonText: (text: string) => {\n\t\t\t\tconsole.log(text);\n\t\t\t},\n\t\t\tonToolUse: (toolName: string) => {\n\t\t\t\tconsole.log(chalk.dim(`  → ${toolName}`));\n\t\t\t},\n\t\t\tonError: (message: string, severity?: 'warning' | 'error') => {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/apps/cli/src/commands/loop.command.ts#L158-L194","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nawait setTaskStatus(tasksPath, '12.3', 'done'); // task 12 doesn't exist\n// after\nconst tasks = await getTasks(tasksPath);\nif (!tasks.some(t => t.id === 12)) throw new Error('Task 12 missing');\nawait setTaskStatus(tasksPath, '12.3', 'done');","handlingStrategy":"validation","validationCode":"const [parentStr] = taskId.split('.');\nconst parentId = parseInt(parentStr, 10);\nconst tasks = JSON.parse(fs.readFileSync(tasksPath, 'utf8')).tasks;\nif (!tasks.some(t => t.id === parentId)) {\n  throw new Error(`Parent task ${parentId} not found; run 'task-master list' for valid IDs`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await setTaskStatus(tasksPath, '7.1', 'done');\n} catch (e) {\n  if (/Parent task \\d+ not found/.test(e.message)) {\n    throw new Error('Stale subtask ID: refresh with task-master list / re-parse PRD');\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["validation","tasks","subtask"],"backgroundTag":"task-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}