eyaltoledano/claude-task-master · error
CORE_FUNCTION_ERROR
CORE_FUNCTION_ERROR
Error message
${error.message} What it means
This is addDependencyDirect's top-level catch handler. Any error thrown while executing the core addDependency logic — file read/write failures, JSON parse errors of tasks.json, unknown task IDs, or filesystem permission problems — is caught and returned as a structured result with code CORE_FUNCTION_ERROR, carrying the original error's message. disableSilentMode() is restored before returning so logging state isn't left corrupted.
Source
Thrown at mcp-server/src/core/direct-functions/add-dependency.js:106
disableSilentMode();
return {
success: true,
data: {
message: `Successfully added dependency: Task ${taskId} now depends on ${dependencyId}`,
taskId: taskId,
dependencyId: dependencyId
}
};
} catch (error) {
// Make sure to restore normal logging even if there's an error
disableSilentMode();
log.error(`Error in addDependencyDirect: ${error.message}`);
return {
success: false,
error: {
code: 'CORE_FUNCTION_ERROR',
message: error.message
}
};
}
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Read result.error.message — it is the underlying core error and usually names the real cause (ENOENT, EACCES, task not found, etc.).
- Verify tasksJsonPath points to an existing, valid tasks.json (check with a JSON linter).
- Confirm both id and dependsOn exist as tasks in the file before calling.
- Check file permissions for the user running the MCP server.
- Avoid concurrent modifications: close other Task Master sessions writing to the same tasks.json.
Example fix
// before
const res = await addDependencyDirect(args);
console.log(res); // opaque failure
// after
const res = await addDependencyDirect(args);
if (!res.success) {
if (res.error.code === 'CORE_FUNCTION_ERROR') {
console.error(`Core addDependency failed: ${res.error.message}`);
}
}
// and validate the file first:
JSON.parse(fs.readFileSync(tasksJsonPath, 'utf8')); Defensive patterns
Strategy: try-catch
Validate before calling
function preflightDependency(args) {
const raw = fs.readFileSync(args.tasksJsonPath, 'utf8');
const data = JSON.parse(raw); // throws on corrupted file
const ids = new Set(data.tasks.map(t => String(t.id)));
if (!ids.has(String(args.id))) throw new Error(`Task ${args.id} not found`);
if (!ids.has(String(args.dependsOn))) throw new Error(`Task ${args.dependsOn} not found`);
fs.accessSync(args.tasksJsonPath, fs.constants.W_OK); // throws if not writable
} 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 addDependencyDirect(args);
if (isCoreFunctionError(result)) {
console.error(`addDependency failed: ${result.error.message}`);
// branch on message: 'not found' -> fix IDs; ENOENT/EACCES -> fix path/permissions
} Prevention
- Always check result.success before using the result — these wrappers return errors, they don't throw.
- Validate tasks.json is parseable JSON and both IDs exist before calling.
- Ensure the MCP server process has write permission on tasks.json.
- Avoid running CLI and MCP writes concurrently on the same tasks.json.
When it happens
Trigger: tasksJsonPath points to a nonexistent or unreadable file; tasks.json contains invalid JSON; id or dependsOn references a task that doesn't exist; the tasks.json file is locked or read-only when the core function tries to write; any exception thrown inside core's addDependency().
Common situations: Running the MCP server with a different working directory or user than the project owner (permission denied); tasks.json corrupted by a merge conflict; referencing a task ID from another project's file; concurrent writes racing between the CLI and the MCP server.
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/f310809177fc5509.
Report an issue: GitHub.