{"record":{"id":"c3b6d77af7d6df42","repo":"eyaltoledano/claude-task-master","slug":"core-function-error-c3b6d7","errorCode":"CORE_FUNCTION_ERROR","errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/remove-subtask.js","lineNumber":123,"sourceCode":"\t\t\t};\n\t\t} else {\n\t\t\t// Return simple success message for deletion\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {\n\t\t\t\t\tmessage: `Subtask ${id} successfully removed`\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\t// Ensure silent mode is disabled even if an outer error occurs\n\t\tdisableSilentMode();\n\n\t\tlog.error(`Error in removeSubtaskDirect: ${error.message}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'CORE_FUNCTION_ERROR',\n\t\t\t\tmessage: error.message\n\t\t\t}\n\t\t};\n\t}\n}\n","sourceCodeStart":105,"sourceCodeEnd":129,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/remove-subtask.js#L105-L129","documentation":"This is the catch-all handler at the end of removeSubtaskDirect: any exception thrown by the wrapper or the core removeSubtask call (e.g. missing tasks.json file, JSON parse failure, subtask not found) is converted into a structured failure with code CORE_FUNCTION_ERROR and the underlying error's message. It means the failure happened inside the core task-manager logic, not in argument validation.","triggerScenarios":"tasksJsonPath points to a nonexistent or unreadable file; tasks.json is malformed JSON; the referenced subtask id does not exist under the parent; file-system permission errors during write-back; any throw inside scripts/modules/task-manager.js removeSubtask.","commonSituations":"Wrong tasksJsonPath (typo or stale path after moving the project); tasks.json corrupted or manually edited with invalid JSON; removing a subtask that was already removed; tag-scoped file missing.","solutions":["Read the `message` in the error payload — it is the raw underlying error and usually names the file or id at fault.","Verify tasksJsonPath exists and is valid JSON (jq . tasks.json) before retrying.","Confirm the subtask id exists in tasks.json under the given parent (and the correct tag).","Check file/directory write permissions for the tasks.json location.","Enable debug logging in the MCP server to capture the full stack from task-manager.removeSubtask."],"exampleFix":"// before\n// opaque CORE_FUNCTION_ERROR: ENOENT: no such file or directory, open '.taskmaster/task.json'\nconst tasksJsonPath = '.taskmaster/task.json';\n// after\nconst tasksJsonPath = '/repo/.taskmaster/tasks.json'; // corrected path\nif (!fs.existsSync(tasksJsonPath)) throw new Error(`tasks.json not found: ${tasksJsonPath}`);","handlingStrategy":"try-catch","validationCode":"function precheck(tasksJsonPath, id) {\n  const fs = require('fs');\n  if (!fs.existsSync(tasksJsonPath)) throw new Error(`tasks.json not found: ${tasksJsonPath}`);\n  const data = JSON.parse(fs.readFileSync(tasksJsonPath, 'utf8'));\n  const [parentId, subId] = String(id).split('.').map(Number);\n  const parent = (data.tasks || []).find((t) => t.id === parentId);\n  if (!parent || !(parent.subtasks || []).some((s) => s.id === subId)) {\n    throw new Error(`Subtask ${id} not found in ${tasksJsonPath}`);\n  }\n}","typeGuard":"function isCoreFunctionError(result) {\n  return typeof result === 'object' && result !== null && result.success === false &&\n    result.error?.code === 'CORE_FUNCTION_ERROR' && typeof result.error.message === 'string';\n}","tryCatchPattern":"const result = await removeSubtaskDirect(args, log);\nif (!result.success && result.error?.code === 'CORE_FUNCTION_ERROR') {\n  console.error(`removeSubtask failed: ${result.error.message}`);\n  // inspect underlying cause: missing file, bad JSON, nonexistent subtask\n}","preventionTips":["Always run precheck existence/JSON-validity checks on tasks.json before mutating calls.","Keep tasks.json under version control so corruption is detectable and reversible.","Verify the subtask exists (parent.subtasks) before removal to avoid not-found throws.","Check write permissions on the tasks directory, since removal rewrites the file.","Read result.error.message first — it carries the underlying exception text."],"tags":["mcp","core-function","error-handling","task-manager"],"backgroundTag":"core-function-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}