{"record":{"id":"79d7a06f0cbf2ae1","repo":"eyaltoledano/claude-task-master","slug":"task-with-id-numerictaskid-not-found","errorCode":null,"errorMessage":"Task with ID ${numericTaskId} not found.","messagePattern":"Task with ID (.+?) not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":149,"sourceCode":"\t\t// --- End Input Validations ---\n\n\t\t// --- Task Loading and Status Check (Keep existing) ---\n\t\tconst data = readJSON(tasksPath, projectRoot, tag);\n\t\tif (!data || !data.tasks)\n\t\t\tthrow new Error(`No valid tasks found in ${tasksPath}.`);\n\t\t// File storage requires a strict numeric task ID\n\t\tconst idStr = String(taskId).trim();\n\t\tif (!/^\\d+$/.test(idStr)) {\n\t\t\tthrow new Error(\n\t\t\t\t'For file storage, taskId must be a positive integer. ' +\n\t\t\t\t\t'Use update-subtask-by-id for IDs like \"1.2\", or run in API storage for display IDs (e.g., \"HAM-123\").'\n\t\t\t);\n\t\t}\n\t\tconst numericTaskId = Number(idStr);\n\t\tconst taskIndex = data.tasks.findIndex((task) => task.id === numericTaskId);\n\t\tif (taskIndex === -1) {\n\t\t\treport('error', `Task with ID ${numericTaskId} not found`);\n\t\t\tthrow new Error(`Task with ID ${numericTaskId} not found.`);\n\t\t}\n\t\tconst taskToUpdate = data.tasks[taskIndex];\n\t\tif (taskToUpdate.status === 'done' || taskToUpdate.status === 'completed') {\n\t\t\treport(\n\t\t\t\t'warn',\n\t\t\t\t`Task ${taskId} is already marked as done and cannot be updated`\n\t\t\t);\n\n\t\t\t// Only show warning box for text output (CLI)\n\t\t\tif (outputFormat === 'text') {\n\t\t\t\tconsole.log(\n\t\t\t\t\tboxen(\n\t\t\t\t\t\tchalk.yellow(\n\t\t\t\t\t\t\t`Task ${taskId} is already marked as ${taskToUpdate.status} and cannot be updated.`\n\t\t\t\t\t\t) +\n\t\t\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t\t\tchalk.white(\n\t\t\t\t\t\t\t\t'Completed tasks are locked to maintain consistency. To modify a completed task, you must first:'","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L131-L167","documentation":"updateTaskById() reads tasks.json, converts the validated numeric ID, and searches data.tasks with findIndex. This error is thrown when no task with that integer id exists in the (tag-scoped) tasks file, after logging the same message via report().","triggerScenarios":"Calling updateTaskById(99, prompt) when tasks.json only has IDs 1-20; querying the wrong tag whose file lacks that ID; the task was deleted or renumbered by another command between listing and updating.","commonSituations":"Hardcoded IDs in scripts after the task list changed; forgetting that IDs are per-tag, so master IDs differ from a feature tag's; stale automation reading an old snapshot of tasks.json.","solutions":["Run 'task-master list' (for the active tag) to confirm the task ID exists","Check the active tag/context — switch tags or pass the correct one so the right tasks file is searched","Update hardcoded IDs in scripts to current ones, or look the ID up dynamically before updating","Restore the missing task from backup/git if it was deleted by mistake"],"exampleFix":"// before\nawait updateTaskById(99, prompt); // may not exist\n// after\nconst data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (data.tasks.some(t => t.id === 99)) {\n  await updateTaskById(99, prompt);\n} else {\n  console.error('Task 99 not found in current tag');\n}","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nconst exists = Array.isArray(data.tasks) && data.tasks.some(t => t.id === numericTaskId);\nif (!exists) throw new Error(`Task ${numericTaskId} not found in ${tasksPath}`);","typeGuard":"function taskExists(tasks, id) {\n  return Array.isArray(tasks) && tasks.some(t => t.id === id);\n}","tryCatchPattern":"try {\n  await updateTaskById(numericTaskId, prompt);\n} catch (err) {\n  if (err.message.includes('not found') && !err.message.includes('Subtask')) {\n    console.error(`Task ${numericTaskId} missing; run 'task-master list' for current IDs`);\n  } else throw err;\n}","preventionTips":["Look up task IDs dynamically (task-master list) rather than hardcoding them","Remember IDs are scoped per tag; verify the active tag before updating","Re-read tasks.json after delete/renumber operations","Handle race conditions in scripts by re-fetching IDs just before the update"],"tags":["task-management","not-found","ids"],"backgroundTag":"task-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}