{"record":{"id":"dd6693557c966a50","repo":"eyaltoledano/claude-task-master","slug":"parent-task-parentid-not-found","errorCode":null,"errorMessage":"Parent task ${parentId} not found","messagePattern":"Parent 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":528,"sourceCode":"\t\t\t);\n\t\t}\n\n\t\tconst [parentId, subIdRaw] = parts;\n\t\tconst subId = subIdRaw.trim();\n\t\tif (!/^\\d+$/.test(subId)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid subtask ID: ${subId}. Subtask ID must be a positive integer.`\n\t\t\t);\n\t\t}\n\t\tconst subtaskNumericId = Number(subId);\n\n\t\t// Find the parent task\n\t\tconst parentTaskIndex = tasks.findIndex(\n\t\t\t(t) => String(t.id) === String(parentId)\n\t\t);\n\n\t\tif (parentTaskIndex === -1) {\n\t\t\tthrow new Error(`Parent task ${parentId} not found`);\n\t\t}\n\n\t\tconst parentTask = tasks[parentTaskIndex];\n\n\t\t// Find the subtask within the parent task\n\t\tconst subtaskIndex = parentTask.subtasks.findIndex(\n\t\t\t(st) => st.id === subtaskNumericId || String(st.id) === subId\n\t\t);\n\n\t\tif (subtaskIndex === -1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Subtask ${subtaskId} not found in parent task ${parentId}`\n\t\t\t);\n\t\t}\n\n\t\tconst oldStatus = parentTask.subtasks[subtaskIndex].status || 'pending';\n\t\tif (oldStatus === newStatus) {\n\t\t\treturn {","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts#L510-L546","documentation":"FileStorage.updateSubtaskStatusInFile parses a dotted subtask ID like '5.2', then looks for a parent task whose id matches the '5' portion in the loaded task list. When no parent task matches, it throws this error and the status update is aborted without writing anything. It is a data-existence error: the subtask ID references a parent that is not present under the active tag.","triggerScenarios":"Calling storage.updateTaskStatus('5.2', 'done') (which routes to updateSubtaskStatusInFile) when task 5 does not exist in the tasks file for the given tag; calling with a parent ID that was deleted; calling while a different --tag is active so the parent lives under another tag; calling before the parent task was created or after tasks.json was manually edited.","commonSituations":"Scripts hardcoding subtask IDs that were renumbered after tasks were reorganized; switching tags (e.g. from 'master' to a feature tag) where the parent only exists in the other tag; manual edits to tasks.json removing tasks while automation still references old IDs; off-by-one or stale IDs cached from a previous API response.","solutions":["List the tasks under the current tag (storage.getTasks(tag)) and confirm the parent ID exists before updating the subtask.","Verify you are operating on the correct tag — pass the same tag to updateTaskStatus that contains the parent task.","Re-fetch current task IDs if they were cached; IDs change when tasks are reorganized or files are re-generated.","Create the parent task first if it genuinely does not exist yet."],"exampleFix":"// before\nawait storage.updateTaskStatus('5.2', 'done');\n// after\nconst tasks = await storage.getTasks(tag);\nif (!tasks.some((t) => String(t.id) === '5')) {\n  throw new Error('Parent task 5 does not exist under tag ' + tag);\n}\nawait storage.updateTaskStatus('5.2', 'done', tag);","handlingStrategy":"validation","validationCode":"const tasks = await storage.getTasks(tag);\nif (!tasks.some((t) => String(t.id) === String(parentId))) {\n  throw new Error(`Parent task ${parentId} does not exist under tag ${tag}`);\n}","typeGuard":"function parentTaskExists(tasks: Task[], parentId: string): tasks is Task[] & { found: true } {\n  return tasks.some((t) => String(t.id) === String(parentId));\n}","tryCatchPattern":"try {\n  await storage.updateTaskStatus('5.2', 'done', tag);\n} catch (err) {\n  if (err instanceof Error && /Parent task .* not found/.test(err.message)) {\n    console.warn(`Skipping 5.2: parent missing under tag ${tag}`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Always resolve subtask IDs from a fresh getTasks() call, never from cached values.","Pass the tag explicitly to every task operation so lookups happen in the right namespace.","Validate dotted IDs (parentId.subtaskId) against the task list before mutating.","Log the active tag alongside errors to spot tag-mismatch bugs quickly."],"tags":["task-management","file-storage","not-found","subtask"],"backgroundTag":"task-id-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}