eyaltoledano/claude-task-master · error
UNEXPECTED_ERROR
UNEXPECTED_ERROR
Error message
error.message
What it means
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.
Source
Thrown at mcp-server/src/core/direct-functions/remove-task.js:137
message: result.message,
tasksPath: tasksJsonPath,
tag
}
};
} finally {
// Restore normal logging
disableSilentMode();
}
} catch (error) {
// Ensure silent mode is disabled even if an outer error occurs
disableSilentMode();
// Catch any unexpected errors
log.error(`Unexpected error in removeTaskDirect: ${error.message}`);
return {
success: false,
error: {
code: 'UNEXPECTED_ERROR',
message: error.message
}
};
}
}
View on GitHub (pinned to c0c98d367c)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate inputs and file parse cleanly before the call
JSON.parse(readFileSync(tasksJsonPath, 'utf8')); // throws early on malformed JSON
if (!projectRoot) throw new Error('projectRoot is required for remove_task'); Try / catch
try {
const res = await client.callTool('remove_task', { id, projectRoot });
if (!res.success && res.error?.code === 'UNEXPECTED_ERROR') {
// Inspect MCP server logs ('Unexpected error in removeTaskDirect') for the stack
console.error('Unexpected server-side failure; check MCP server logs');
}
} catch (e) {
console.error('Transport/client failure:', e.message);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- UNEXPECTED_ERROR
- UNEXPECTED_ERROR
- projectRoot is required in args to resolve project paths
- MCP provider requires session object
- The MCP model function cannot be called with the new keyword
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/5c026b0f0c2e8555.
Report an issue: GitHub.