{"record":{"id":"5c026b0f0c2e8555","repo":"eyaltoledano/claude-task-master","slug":"unexpected-error-5c026b","errorCode":"UNEXPECTED_ERROR","errorMessage":"error.message","messagePattern":"error\\.message","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/remove-task.js","lineNumber":137,"sourceCode":"\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}\n\t\t\t};\n\t\t} finally {\n\t\t\t// Restore normal logging\n\t\t\tdisableSilentMode();\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\t// Catch any unexpected errors\n\t\tlog.error(`Unexpected error in removeTaskDirect: ${error.message}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'UNEXPECTED_ERROR',\n\t\t\t\tmessage: error.message\n\t\t\t}\n\t\t};\n\t}\n}\n","sourceCodeStart":119,"sourceCodeEnd":143,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/remove-task.js#L119-L143","documentation":"removeTaskDirect wraps its whole body in a try/catch. Any exception not converted to a structured result — e.g. thrown by readJSON, the core removal, or logging setup — is caught here and re-emitted as UNEXPECTED_ERROR with the exception's message. It signals a failure outside the function's expected error paths.","triggerScenarios":"readJSON throwing on unreadable/corrupt file in a way not handled earlier, unexpected exceptions from the core remove-task module, silent-mode/logging helpers throwing, or a programming error (undefined access) inside the flow.","commonSituations":"tasks.json contains malformed JSON that readJSON surfaces as a throw; permission errors on the file; a version mismatch between the MCP server and tm-core; null projectRoot causing a deep undefined dereference.","solutions":["Inspect the server log line 'Unexpected error in removeTaskDirect' for the underlying stack and fix that root cause","Validate tasks.json parses as proper JSON (jq . tasks.json)","Confirm projectRoot/tasksJsonPath point at a readable .taskmaster workspace","Reproduce via CLI (task-master remove-task) to see the full stack trace; file an issue if it looks like an internal bug"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate inputs and file parse cleanly before the call\nJSON.parse(readFileSync(tasksJsonPath, 'utf8')); // throws early on malformed JSON\nif (!projectRoot) throw new Error('projectRoot is required for remove_task');","typeGuard":null,"tryCatchPattern":"try {\n  const res = await client.callTool('remove_task', { id, projectRoot });\n  if (!res.success && res.error?.code === 'UNEXPECTED_ERROR') {\n    // Inspect MCP server logs ('Unexpected error in removeTaskDirect') for the stack\n    console.error('Unexpected server-side failure; check MCP server logs');\n  }\n} catch (e) {\n  console.error('Transport/client failure:', e.message);\n}","preventionTips":["Keep server logs enabled — the underlying stack is logged on the server side","Validate tasks.json is well-formed JSON before mutating operations","Run the equivalent CLI command to reproduce with a full stack trace","Pin matching versions of task-master-ai packages to avoid internal API drift"],"tags":["mcp","unexpected-error","exception"],"backgroundTag":"unexpected-exception","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}