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

  1. Inspect result.error.message for the underlying cause (task not found, ENOENT, EACCES, JSON parse error).
  2. Verify both the parent id and the optional taskId exist in tasks.json.
  3. Validate that tasksJsonPath points to well-formed JSON before retrying.
  4. Fix filesystem permissions for the MCP server process.
  5. 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

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


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/eaab65e76701368d. Report an issue: GitHub.