{"record":{"id":"eff8e47be178bb0c","repo":"eyaltoledano/claude-task-master","slug":"subtask-with-id-subtaskid-not-found-please-ver","errorCode":null,"errorMessage":"Subtask with ID ${subtaskId} not found. Please verify the subtask ID and try again.","messagePattern":"Subtask with ID (.+?) not found\\. Please verify the subtask ID and try again\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-subtask-by-id.js","lineNumber":170,"sourceCode":"\t\t\t);\n\t\t}\n\n\t\tconst parentTask = data.tasks.find((task) => task.id === parentId);\n\t\tif (!parentTask) {\n\t\t\tthrow new Error(\n\t\t\t\t`Parent task with ID ${parentId} not found. Please verify the task ID and try again.`\n\t\t\t);\n\t\t}\n\n\t\tif (!parentTask.subtasks || !Array.isArray(parentTask.subtasks)) {\n\t\t\tthrow new Error(`Parent task ${parentId} has no subtasks.`);\n\t\t}\n\n\t\tconst subtaskIndex = parentTask.subtasks.findIndex(\n\t\t\t(st) => st.id === subtaskIdNum\n\t\t);\n\t\tif (subtaskIndex === -1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Subtask with ID ${subtaskId} not found. Please verify the subtask ID and try again.`\n\t\t\t);\n\t\t}\n\n\t\tconst subtask = parentTask.subtasks[subtaskIndex];\n\n\t\t// --- Metadata-Only Update (Fast Path) ---\n\t\t// If only metadata is provided (no prompt), skip AI and just update metadata\n\t\tif (metadata && (!prompt || prompt.trim() === '')) {\n\t\t\treport('info', `Metadata-only update for subtask ${subtaskId}`);\n\t\t\t// Merge new metadata with existing\n\t\t\tsubtask.metadata = {\n\t\t\t\t...(subtask.metadata || {}),\n\t\t\t\t...metadata\n\t\t\t};\n\t\t\tparentTask.subtasks[subtaskIndex] = subtask;\n\t\t\twriteJSON(tasksPath, data, projectRoot, tag);\n\t\t\treport(","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-subtask-by-id.js#L152-L188","documentation":"updateSubtaskById() parses the parent.subtask ID and searches the parent's subtasks array with findIndex. This error is thrown when the parent task and its subtasks exist but no subtask matches the given subtask number, meaning the referenced subtask does not exist.","triggerScenarios":"Calling updateSubtaskById with e.g. '5.7' when task 5 only has subtasks 1-3; passing the full string '5.7' after the parent lookup succeeded but st.id === subtaskIdNum finds no match.","commonSituations":"Off-by-one or out-of-range subtask numbers; stale IDs after subtasks were removed/renumbered; confusing global subtask numbering with per-parent numbering; reading IDs from an outdated task list.","solutions":["List the parent task's subtasks ('task-master list --with-subtasks' or read tasks.json) and use a valid subtask number","Verify you are using the correct parent ID in parent.subtask form (5.2, not 2 or 7)","Re-fetch the latest tasks.json if subtasks were recently modified by another process","If the subtask should exist, restore it or recreate it before updating"],"exampleFix":"// before\nawait updateSubtaskById('5.7', prompt); // subtask 7 may not exist\n// after\nconst parent = tasks.find(t => t.id === 5);\nconst max = parent?.subtasks?.length ?? 0;\nif (subtaskNum <= max) await updateSubtaskById(`5.${subtaskNum}`, prompt);","handlingStrategy":"validation","validationCode":"const [pid, sid] = subtaskId.split('.').map(Number);\nconst parent = data.tasks.find(t => t.id === pid);\nconst exists = parent?.subtasks?.some(st => st.id === sid);\nif (!exists) throw new Error(`Subtask ${subtaskId} does not exist`);","typeGuard":"function subtaskExists(tasks, parentId, subtaskId) {\n  const parent = tasks.find(t => t.id === parentId);\n  return !!parent?.subtasks?.some(st => st.id === subtaskId);\n}","tryCatchPattern":"try {\n  await updateSubtaskById(subtaskId, prompt);\n} catch (err) {\n  if (err.message.includes('Subtask with ID') && err.message.includes('not found')) {\n    console.error(`Invalid subtask ${subtaskId}; list the parent task to get valid IDs`);\n  } else throw err;\n}","preventionTips":["Resolve subtask IDs dynamically from the current task list instead of hardcoding them","Remember subtask numbering is per-parent (5.1, 5.2), not global","Re-read tasks.json after any command that adds/removes subtasks","Validate the parent.subtask format before invoking the API"],"tags":["task-management","validation","subtasks","not-found"],"backgroundTag":"subtask-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}