{"record":{"id":"8df0203b023b9c0d","repo":"eyaltoledano/claude-task-master","slug":"input-validation-error-8df020","errorCode":"INPUT_VALIDATION_ERROR","errorMessage":"Parent task ID is required","messagePattern":"Parent task ID is required","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/add-subtask.js","lineNumber":62,"sourceCode":"\t\tlog.info(`Adding subtask with args: ${JSON.stringify(args)}`);\n\n\t\t// Check if tasksJsonPath was provided\n\t\tif (!tasksJsonPath) {\n\t\t\tlog.error('addSubtaskDirect called without tasksJsonPath');\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'MISSING_ARGUMENT',\n\t\t\t\t\tmessage: 'tasksJsonPath is required'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tif (!id) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'INPUT_VALIDATION_ERROR',\n\t\t\t\t\tmessage: 'Parent task ID is required'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// Either taskId or title must be provided\n\t\tif (!taskId && !title) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'INPUT_VALIDATION_ERROR',\n\t\t\t\t\tmessage: 'Either taskId or title must be provided'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// Use provided path\n\t\tconst tasksPath = tasksJsonPath;","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/add-subtask.js#L44-L80","documentation":"addSubtaskDirect validates that id — the parent task under which the subtask will be added — is provided. A missing id returns a structured INPUT_VALIDATION_ERROR result. Without a parent task the core function cannot decide where to insert the new subtask.","triggerScenarios":"Calling add_subtask with only title/taskId (creating a subtask payload) but omitting the parent id; a client sending parentId instead of id; generated tool calls dropping the first positional-style argument.","commonSituations":"Confusion between the parent id and the optional existing taskId (task to convert into a subtask); LLM tool calls that omit arguments they consider inferable; migrating scripts from a CLI flag spelling (--parent) to the MCP argument spelling.","solutions":["Include id with the parent task's ID (e.g. '1' or 'HAM-12').","Match argument names exactly to the tool schema (id, not parentId or parent).","Ensure the parent task exists in tasks.json before adding the subtask.","If you meant to convert an existing task into a subtask, pass id (parent) plus taskId (the existing task)."],"exampleFix":"// before\nawait addSubtaskDirect({ tasksJsonPath, title: 'Write tests' });\n// after\nawait addSubtaskDirect({ tasksJsonPath, id: '1', title: 'Write tests' });","handlingStrategy":"validation","validationCode":"function assertParentId(args) {\n  const id = args?.id;\n  if (typeof id !== 'string' || id.trim() === '') {\n    throw new Error('Parent task ID (id) is required');\n  }\n  const data = JSON.parse(fs.readFileSync(args.tasksJsonPath, 'utf8'));\n  if (!data.tasks?.some(t => String(t.id) === id)) {\n    throw new Error(`Parent task ${id} not found in tasks.json`);\n  }\n}","typeGuard":"function hasParentId(args) {\n  return typeof args?.id === 'string' && args.id.trim().length > 0;\n}","tryCatchPattern":"if (!hasParentId(args)) {\n  return { success: false, error: { code: 'INPUT_VALIDATION_ERROR', message: 'Parent task ID is required' } };\n}","preventionTips":["Distinguish clearly: id = parent task, taskId = existing task to convert, title = new subtask name.","Confirm the parent exists before adding subtasks to it.","Keep argument names aligned with the tool schema (id, not parentId).","Centralize tool-call construction in one typed helper."],"tags":["validation","mcp","missing-argument","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}