{"record":{"id":"342bf95cff7f090b","repo":"eyaltoledano/claude-task-master","slug":"invalid-task-id","errorCode":"INVALID_TASK_ID","errorMessage":"The following tasks were not found${tag ? ` in tag '${tag}'` : ''}: ${invalidTasks.join(', ')}","messagePattern":"The following tasks were not found(.+?)'` : ''\\}: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/remove-task.js","lineNumber":84,"sourceCode":"\t\tif (!data || !data.tasks) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'INVALID_TASKS_FILE',\n\t\t\t\t\tmessage: `No valid tasks found in ${tasksJsonPath}${tag ? ` for tag '${tag}'` : ''}`\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tconst invalidTasks = taskIdArray.filter(\n\t\t\t(taskId) => !taskExists(data.tasks, taskId)\n\t\t);\n\n\t\tif (invalidTasks.length > 0) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'INVALID_TASK_ID',\n\t\t\t\t\tmessage: `The following tasks were not found${tag ? ` in tag '${tag}'` : ''}: ${invalidTasks.join(', ')}`\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// Enable silent mode to prevent console logs from interfering with JSON response\n\t\tenableSilentMode();\n\n\t\ttry {\n\t\t\t// Call removeTask with proper context including tag\n\t\t\tconst result = await removeTask(tasksJsonPath, id, {\n\t\t\t\tprojectRoot,\n\t\t\t\ttag\n\t\t\t});\n\n\t\t\tif (!result.success) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/remove-task.js#L66-L102","documentation":"removeTaskDirect pre-validates that every requested id exists in the tasks file for the active tag. If any ids do not resolve to real tasks, it aborts atomically with INVALID_TASK_ID listing all missing ids rather than partially deleting.","triggerScenarios":"Calling remove_task with ids that are absent from tasks.json: already-deleted ids, out-of-range numeric ids, typos, comma-separated lists where one id is stale, or ids that exist only in a different tag than the one selected.","commonSituations":"An agent cached old task ids that were renumbered after updates; user removed tasks in the CLI then repeats the call in MCP; cross-tag confusion (id 3 exists in tag 'backlog' but active tag is 'master'); fat-fingered id like '99' in a 20-task project.","solutions":["List current tasks (get_tasks / task-master list) and retry remove_task with only ids that exist under the active tag","Switch to the correct tag argument if the tasks live in another tag","Remove the invalid ids from the comma-separated list and keep only valid ones","If the task was already removed, treat this as success and skip the duplicate call"],"exampleFix":"// before\nawait client.callTool('remove_task', { id: '5,12' }); // 12 no longer exists\n\n// after\nawait client.callTool('remove_task', { id: '5', projectRoot: '/path/to/project' });","handlingStrategy":"validation","validationCode":"const existing = new Set(tasks.map(t => String(t.id)));\nconst invalid = ids.filter(i => !existing.has(String(i)));\nif (invalid.length > 0) throw new Error(`Unknown task ids: ${invalid.join(', ')}`);","typeGuard":"function allIdsExist(ids, tasks) {\n  const known = new Set(tasks.map(t => String(t.id)));\n  return Array.isArray(ids) && ids.length > 0 && ids.every(i => known.has(String(i)));\n}","tryCatchPattern":"try {\n  const res = await client.callTool('remove_task', { id: ids.join(','), projectRoot });\n  if (res.error?.code === 'INVALID_TASK_ID') {\n    const missing = res.error.message.split(':')[1]?.trim();\n    console.error(`Re-fetch task list; these ids do not exist in the active tag: ${missing}`);\n  }\n} catch (e) {\n  console.error('remove_task failed:', e.message);\n}","preventionTips":["Refresh the task list right before removing instead of using cached ids","Verify the active tag matches where the target tasks actually live","Treat a 'not found' result on removal as possibly 'already removed' and skip retries","Copy ids directly from list output rather than retyping them"],"tags":["mcp","validation","task-id"],"backgroundTag":"resource-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}