{"record":{"id":"fb79cbea5887b650","repo":"eyaltoledano/claude-task-master","slug":"task-taskid-not-found-fb79cb","errorCode":null,"errorMessage":"Task ${taskId} not found","messagePattern":"Task (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts","lineNumber":373,"sourceCode":"\tasync appendTasks(tasks: Task[], tag?: string): Promise<void> {\n\t\tconst existingTasks = await this.loadTasks(tag);\n\t\tconst allTasks = [...existingTasks, ...tasks];\n\t\tawait this.saveTasks(allTasks, tag);\n\t}\n\n\t/**\n\t * Update a specific task\n\t */\n\tasync updateTask(\n\t\ttaskId: string,\n\t\tupdates: Partial<Task>,\n\t\ttag?: string\n\t): Promise<void> {\n\t\tconst tasks = await this.loadTasks(tag);\n\t\tconst taskIndex = tasks.findIndex((t) => String(t.id) === String(taskId));\n\n\t\tif (taskIndex === -1) {\n\t\t\tthrow new Error(`Task ${taskId} not found`);\n\t\t}\n\n\t\tconst existingTask = tasks[taskIndex];\n\n\t\t// Preserve subtask metadata when subtasks are updated\n\t\t// AI operations don't include metadata in returned subtasks\n\t\tlet mergedSubtasks = updates.subtasks;\n\t\tif (updates.subtasks && existingTask.subtasks) {\n\t\t\tmergedSubtasks = updates.subtasks.map((updatedSubtask) => {\n\t\t\t\t// Type-coerce IDs for comparison; fall back to title match if IDs don't match\n\t\t\t\tconst originalSubtask = existingTask.subtasks?.find(\n\t\t\t\t\t(st) =>\n\t\t\t\t\t\tString(st.id) === String(updatedSubtask.id) ||\n\t\t\t\t\t\t(updatedSubtask.title && st.title === updatedSubtask.title)\n\t\t\t\t);\n\t\t\t\t// Merge metadata: preserve original and add/override with new\n\t\t\t\tif (originalSubtask?.metadata || updatedSubtask.metadata) {\n\t\t\t\t\treturn {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts#L355-L391","documentation":"updateTask() loads all tasks for the active tag and searches for one whose id matches taskId. If no task matches, it throws this error rather than silently failing; the caller must supply an ID of an existing task in the current tag.","triggerScenarios":"Calling updateTask with an ID that does not exist in the active tag's task list, passing a numeric id as a string with unexpected formatting (though matching is done via String() comparison so both '1' and 1 work), or operating against the wrong tag where the task lives under a different tag.","commonSituations":"Task was deleted by another process/session before the update, hard-coded task IDs from an old tasks.json, CLI user mistypes an ID, or the default tag differs from the tag the task belongs to.","solutions":["List tasks in the active tag (tmCore.tasks.get() / 'task-master list') and confirm the ID exists","Pass the correct tag parameter if the task lives in another tag","Re-check whether the task was deleted or completed and removed","If parsing user input, validate the ID format before calling"],"exampleFix":"// before\nawait storage.updateTask('42', updates); // throws if task 42 does not exist\n// after\nconst tasks = await storage.loadTasks();\nif (tasks.some((t) => String(t.id) === '42')) {\n  await storage.updateTask('42', updates);\n}","handlingStrategy":"validation","validationCode":"async function taskExists(storage: FileStorage, taskId: string, tag?: string) {\n  const tasks = await storage.loadTasks(tag);\n  return tasks.some((t) => String(t.id) === String(taskId));\n}\n// call only if (await taskExists(storage, '42')) ...","typeGuard":"function isTaskNotFoundError(e: unknown, taskId?: string): e is Error {\n  return e instanceof Error &&\n    e.message === `Task ${taskId ?? ''} not found` ||\n    (e instanceof Error && /^Task .+ not found$/.test(e.message));\n}","tryCatchPattern":"try {\n  await storage.updateTask(taskId, updates);\n} catch (e) {\n  if (/^Task .+ not found$/.test((e as Error).message)) {\n    // refresh task list / inform user the ID no longer exists\n  } else throw e;\n}","preventionTips":["Always resolve task IDs from a fresh loadTasks() call, not stale caches","Pass the tag explicitly when tasks live outside the default tag","Validate user-supplied IDs against the current list before updating","Re-read tasks.json after external processes may have modified it"],"tags":["task-not-found","storage","validation"],"backgroundTag":"task-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}