{"record":{"id":"34edb60be0dab87c","repo":"eyaltoledano/claude-task-master","slug":"core-function-error-34edb6","errorCode":"CORE_FUNCTION_ERROR","errorMessage":"${error.message} || 'Failed to expand task'","messagePattern":"(.+?) \\|\\| 'Failed to expand task'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/expand-task.js","lineNumber":249,"sourceCode":"\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {\n\t\t\t\t\ttask: coreResult.task,\n\t\t\t\t\tsubtasksAdded,\n\t\t\t\t\thasExistingSubtasks,\n\t\t\t\t\ttelemetryData: coreResult.telemetryData,\n\t\t\t\t\ttagInfo: coreResult.tagInfo\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (error) {\n\t\t\t// Make sure to restore normal logging even if there's an error\n\t\t\tif (!wasSilent && isSilentMode()) disableSilentMode();\n\n\t\t\tlog.error(`Error expanding task: ${error.message}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'CORE_FUNCTION_ERROR',\n\t\t\t\t\tmessage: error.message || 'Failed to expand task'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\tlog.error(`Error expanding task: ${error.message}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'CORE_FUNCTION_ERROR',\n\t\t\t\tmessage: error.message || 'Failed to expand task'\n\t\t\t}\n\t\t};\n\t}\n}\n","sourceCodeStart":231,"sourceCodeEnd":265,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/expand-task.js#L231-L265","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the server log line 'Error expanding task: ...' — it contains the real underlying message","Verify tasksJsonPath points to a valid tasks.json (run list_tasks against the same path)","Confirm the AI provider is configured (API key/model) since expansion calls the LLM","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"],"exampleFix":"// before\nawait mcp.call('expand_task', { projectRoot: '/wrong/path' });\n// after\nawait mcp.call('expand_task', { projectRoot: '/repo', tasksJsonPath: '/repo/.taskmaster/tasks/tasks.json' });","handlingStrategy":"try-catch","validationCode":"const tasksPath = path.join(projectRoot, '.taskmaster/tasks/tasks.json');\nif (!fs.existsSync(tasksPath)) throw new Error(`tasks.json missing at ${tasksPath}`);\nJSON.parse(fs.readFileSync(tasksPath, 'utf8')); // throws early on corrupt file","typeGuard":"function isCoreFunctionError(res) {\n  return res && res.success === false && res.error?.code === 'CORE_FUNCTION_ERROR';\n}","tryCatchPattern":"const res = await callTool('expand_task', { taskId, projectRoot });\nif (!res.success && res.error?.code === 'CORE_FUNCTION_ERROR') {\n  if (res.error.message === 'Failed to expand task') {\n    // fallback message: reproduce via CLI for a real stack\n    console.error('expand_task failed without detail; run: task-master expand --id=' + taskId);\n  } else {\n    console.error('expand_task failed:', res.error.message);\n  }\n}","preventionTips":["Always read error.message — it is the real core error, the code is generic","Keep tasks.json valid JSON; validate after manual edits","Ensure the AI provider (API key/model) is configured before expanding","Match the CLI behavior to reproduce errors with full stacks"],"tags":["mcp","error-handling","wrapper"],"backgroundTag":"core-function-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}