{"record":{"id":"793f4bad0b20550d","repo":"eyaltoledano/claude-task-master","slug":"task-taskid-not-found-793f4b","errorCode":null,"errorMessage":"Task ${taskId} not found","messagePattern":"Task (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/expand-task.js","lineNumber":103,"sourceCode":"\t\t\treport\n\t\t});\n\n\t\t// If remote handled it, return the result\n\t\tif (remoteResult) {\n\t\t\treturn remoteResult;\n\t\t}\n\t\t// Otherwise fall through to file-based logic below\n\t\t// --- End BRIDGE ---\n\n\t\t// --- Task Loading/Filtering (Unchanged) ---\n\t\tlogger.info(`Reading tasks from ${tasksPath}`);\n\t\tconst data = readJSON(tasksPath, projectRoot, tag);\n\t\tif (!data || !data.tasks)\n\t\t\tthrow new Error(`Invalid tasks data in ${tasksPath}`);\n\t\tconst taskIndex = data.tasks.findIndex(\n\t\t\t(t) => t.id === parseInt(taskId, 10)\n\t\t);\n\t\tif (taskIndex === -1) throw new Error(`Task ${taskId} not found`);\n\t\tconst task = data.tasks[taskIndex];\n\t\tlogger.info(\n\t\t\t`Expanding task ${taskId}: ${task.title}${useResearch ? ' with research' : ''}`\n\t\t);\n\t\t// --- End Task Loading/Filtering ---\n\n\t\t// --- Handle Force Flag: Clear existing subtasks if force=true ---\n\t\tif (force && Array.isArray(task.subtasks) && task.subtasks.length > 0) {\n\t\t\tlogger.info(\n\t\t\t\t`Force flag set. Clearing existing ${task.subtasks.length} subtasks for task ${taskId}.`\n\t\t\t);\n\t\t\ttask.subtasks = []; // Clear existing subtasks\n\t\t}\n\t\t// --- End Force Flag Handling ---\n\n\t\t// --- Context Gathering ---\n\t\tlet gatheredContext = '';\n\t\ttry {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/expand-task.js#L85-L121","documentation":"After loading a valid tasks array, expandTask() searches for a task whose id equals parseInt(taskId, 10). If no task matches, it throws 'Task <id> not found' rather than expanding a nonexistent item.","triggerScenarios":"Calling expandTask with an ID that does not exist in the current tasks file — a typo, an out-of-range ID, a subtask-style ID like '1.2' (parseInt yields 1 unless exact match exists... here strictly integer matching), or an ID belonging to a different tag's file.","commonSituations":"Referring to a subtask ID (e.g. 5.2) where expandTask expects a top-level task ID; task list changed after deletion/next renumbering; querying the wrong tag; ID from a stale complexity report or console output.","solutions":["Run `task-master list` (or read tasks.json) to confirm the exact top-level task ID, then retry with that numeric ID.","If you meant a subtask, use expand-task with the parent task ID — subtask expansion is handled differently.","Check the active tag; switch to the tag containing the task (task-master use-tag <tag>)."],"exampleFix":"// before\nawait expandTask('42');   // no task 42\n// after\nawait expandTask('12');   // verified via task-master list","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nconst numericId = parseInt(taskId, 10);\nif (!data.tasks.some((t) => t.id === numericId)) {\n  throw new Error(`Task ${numericId} does not exist; use task-master list to find valid IDs`);\n}","typeGuard":"function taskExists(tasks, id) {\n  return tasks.some((t) => t.id === Number(id));\n}","tryCatchPattern":"try {\n  await expandTask(taskId, context);\n} catch (err) {\n  if (/Task \\d+ not found/.test(err.message)) {\n    console.error(`No task with id ${taskId} — check 'task-master list' and the active tag.`);\n  } else throw err;\n}","preventionTips":["List tasks and copy exact IDs before expanding.","Remember expandTask takes top-level numeric IDs, not subtask IDs like 5.2.","Check the active tag matches where the task lives."],"tags":["task-not-found","input-validation","id-lookup"],"backgroundTag":"entity-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}