eyaltoledano/claude-task-master · error

CORE_FUNCTION_ERROR

CORE_FUNCTION_ERROR

Error message

${error.message} || 'Failed to expand task'

What it means

Generic failure wrapper inside expandTaskDirect's inner try/catch: any error thrown by the core expandTask logic (tasks.utils) while silent mode was enabled is logged and returned as CORE_FUNCTION_ERROR with the underlying error.message, or the fallback text 'Failed to expand task' when the error has no message. This is the passthrough for core-layer failures, not a specific validation error.

Source

Thrown at mcp-server/src/core/direct-functions/expand-task.js:249

			return {
				success: true,
				data: {
					task: coreResult.task,
					subtasksAdded,
					hasExistingSubtasks,
					telemetryData: coreResult.telemetryData,
					tagInfo: coreResult.tagInfo
				}
			};
		} catch (error) {
			// Make sure to restore normal logging even if there's an error
			if (!wasSilent && isSilentMode()) disableSilentMode();

			log.error(`Error expanding task: ${error.message}`);
			return {
				success: false,
				error: {
					code: 'CORE_FUNCTION_ERROR',
					message: error.message || 'Failed to expand task'
				}
			};
		}
	} catch (error) {
		log.error(`Error expanding task: ${error.message}`);
		return {
			success: false,
			error: {
				code: 'CORE_FUNCTION_ERROR',
				message: error.message || 'Failed to expand task'
			}
		};
	}
}

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Read the server log line 'Error expanding task: ...' — it contains the real underlying message
  2. Verify tasksJsonPath points to a valid tasks.json (run list_tasks against the same path)
  3. Confirm the AI provider is configured (API key/model) since expansion calls the LLM
  4. If message is the fallback 'Failed to expand task', instrument or re-run the equivalent CLI command (task-master expand --id=N) to surface the raw error

Example fix

// before
await mcp.call('expand_task', { projectRoot: '/wrong/path' });
// after
await mcp.call('expand_task', { projectRoot: '/repo', tasksJsonPath: '/repo/.taskmaster/tasks/tasks.json' });
Defensive patterns

Strategy: try-catch

Validate before calling

const tasksPath = path.join(projectRoot, '.taskmaster/tasks/tasks.json');
if (!fs.existsSync(tasksPath)) throw new Error(`tasks.json missing at ${tasksPath}`);
JSON.parse(fs.readFileSync(tasksPath, 'utf8')); // throws early on corrupt file

Type guard

function isCoreFunctionError(res) {
  return res && res.success === false && res.error?.code === 'CORE_FUNCTION_ERROR';
}

Try / catch

const res = await callTool('expand_task', { taskId, projectRoot });
if (!res.success && res.error?.code === 'CORE_FUNCTION_ERROR') {
  if (res.error.message === 'Failed to expand task') {
    // fallback message: reproduce via CLI for a real stack
    console.error('expand_task failed without detail; run: task-master expand --id=' + taskId);
  } else {
    console.error('expand_task failed:', res.error.message);
  }
}

Prevention

When it happens

Trigger: Any exception from the core expandTask call: unreadable tasks.json, JSON parse failure, task ID not found, complexity-report read errors, or AI provider failures during subtask generation.

Common situations: Corrupted or hand-edited tasks.json; wrong tasksJsonPath; missing API key for the configured AI provider; empty message errors from third-party libraries surfacing the fallback string.

Related errors


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