eyaltoledano/claude-task-master · error
CORE_FUNCTION_ERROR
CORE_FUNCTION_ERROR
Error message
${error.message} What it means
This is addSubtaskDirect's top-level catch handler. Exceptions raised by the core addSubtask logic — missing parent task, nonexistent taskId, invalid tasks.json, or write failures — are caught and returned as a structured CORE_FUNCTION_ERROR result carrying the original message, with disableSilentMode() restoring logging state first.
Source
Thrown at mcp-server/src/core/direct-functions/add-subtask.js:168
disableSilentMode();
return {
success: true,
data: {
message: `New subtask ${parentId}.${result.id} successfully created`,
subtask: result
}
};
}
} catch (error) {
// Make sure to restore normal logging even if there's an error
disableSilentMode();
log.error(`Error in addSubtaskDirect: ${error.message}`);
return {
success: false,
error: {
code: 'CORE_FUNCTION_ERROR',
message: error.message
}
};
}
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Inspect result.error.message for the underlying cause (task not found, ENOENT, EACCES, JSON parse error).
- Verify both the parent id and the optional taskId exist in tasks.json.
- Validate that tasksJsonPath points to well-formed JSON before retrying.
- Fix filesystem permissions for the MCP server process.
- Retry after resolving the cause; the wrapper never throws, so always check result.success.
Example fix
// before
const res = await addSubtaskDirect(args); // throws nothing, may fail silently
// after
const res = await addSubtaskDirect(args);
if (!res.success && res.error.code === 'CORE_FUNCTION_ERROR') {
console.error(`addSubtask failed: ${res.error.message}`);
process.exitCode = 1;
} Defensive patterns
Strategy: try-catch
Validate before calling
function preflightSubtask(args) {
const data = JSON.parse(fs.readFileSync(args.tasksJsonPath, 'utf8'));
const ids = new Set(data.tasks.map(t => String(t.id)));
if (!ids.has(String(args.id))) throw new Error(`Parent task ${args.id} not found`);
if (args.taskId && !ids.has(String(args.taskId))) throw new Error(`Task ${args.taskId} not found`);
fs.accessSync(args.tasksJsonPath, fs.constants.W_OK);
} Type guard
function isCoreFunctionError(result) {
return result?.success === false && result?.error?.code === 'CORE_FUNCTION_ERROR' && typeof result.error.message === 'string';
} Try / catch
const result = await addSubtaskDirect(args);
if (isCoreFunctionError(result)) {
console.error(`addSubtask failed: ${result.error.message}`);
// 'not found' -> fix IDs; ENOENT/EACCES/parse errors -> fix file path/permissions/content
} Prevention
- Always inspect result.success — the wrapper returns errors instead of throwing.
- Verify parent id and optional taskId exist in tasks.json before calling.
- Keep tasks.json valid JSON (lint it after manual edits or merges).
- Ensure the MCP server user can write to the project directory.
- Serialize writes: don't run CLI and MCP mutations on tasks.json simultaneously.
When it happens
Trigger: Parent id does not exist in tasks.json; taskId references a task that cannot be found; tasks.json is malformed JSON or unreadable; the write-back fails (read-only file, disk full, permission denied); any throw inside core's addSubtask().
Common situations: Stale task IDs after tasks.json was regenerated; tasks.json corrupted by merge conflicts; the MCP server running as a user without write access to the project; concurrent CLI/MCP sessions racing on the same file.
Related errors
- CORE_FUNCTION_ERROR
- UPDATE_TASK_CORE_ERROR
- UPDATE_TASKS_CORE_ERROR
- ANALYZE_REPORT_MISSING
- FILE_NOT_FOUND
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/eaab65e76701368d.
Report an issue: GitHub.