{"record":{"id":"72c88c8d0d275e11","repo":"eyaltoledano/claude-task-master","slug":"remove-task-error","errorCode":"REMOVE_TASK_ERROR","errorMessage":"result.error || 'Failed to remove tasks'","messagePattern":"result\\.error \\|\\| 'Failed to remove tasks'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/remove-task.js","lineNumber":104,"sourceCode":"\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,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: 'REMOVE_TASK_ERROR',\n\t\t\t\t\t\tmessage: result.error || 'Failed to remove tasks'\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlog.info(`Successfully removed ${result.removedTasks.length} task(s)`);\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {\n\t\t\t\t\ttotalTasks: taskIdArray.length,\n\t\t\t\t\tsuccessful: result.removedTasks.length,\n\t\t\t\t\tfailed: taskIdArray.length - result.removedTasks.length,\n\t\t\t\t\tremovedTasks: result.removedTasks,\n\t\t\t\t\tmessage: result.message,\n\t\t\t\t\ttasksPath: tasksJsonPath,\n\t\t\t\t\ttag\n\t\t\t\t}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/remove-task.js#L86-L122","documentation":"After passing pre-validation, removeTaskDirect delegates the actual removal to the core remove-task logic. If that core call reports success=false, the direct function forwards the core's error message under REMOVE_TASK_ERROR. This surfaces failures that happen during the removal itself (dependency checks, file writes, etc.).","triggerScenarios":"The core removeTasks operation fails after id validation: filesystem write failures (read-only dir, permissions), errors thrown inside the core removal routine, or tag-scoped data mutations failing during the write-back.","commonSituations":"tasks.json is read-only or owned by another user; disk full; the file was modified concurrently between validation and write; projectRoot misconfigured so supporting state files cannot be written; a bug/regression in the core remove logic.","solutions":["Read the returned `message` — it is the underlying core error; fix the condition it describes (usually file permission or state issue)","Check that tasks.json and its containing directories are writable by the process running the MCP server","Retry after confirming no concurrent process (editor, CLI) is holding/rewriting tasks.json","Upgrade task-master-ai if the message points to an internal core error; report the core error if it persists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check writability of the workspace before mutating calls\nimport { accessSync, constants } from 'fs';\ntry { accessSync(tasksJsonPath, constants.W_OK); } catch { throw new Error(`tasks.json is not writable: ${tasksJsonPath}`); }","typeGuard":null,"tryCatchPattern":"try {\n  const res = await client.callTool('remove_task', { id, projectRoot });\n  if (!res.success && res.error?.code === 'REMOVE_TASK_ERROR') {\n    // res.error.message carries the underlying core failure (permissions, concurrent write, etc.)\n    console.error(`Core removal failed: ${res.error.message}`);\n  }\n} catch (e) {\n  console.error('remove_task failed:', e.message);\n}","preventionTips":["Ensure the MCP server process has write access to .taskmaster and tasks.json","Avoid running CLI and MCP mutations on the same tasks.json concurrently","Keep tm-core and the MCP server versions in sync","Back up tasks.json before bulk removals"],"tags":["mcp","filesystem","removal-failed"],"backgroundTag":"operation-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}