{"record":{"id":"f89c6919b39f780f","repo":"eyaltoledano/claude-task-master","slug":"core-function-error-f89c69","errorCode":"CORE_FUNCTION_ERROR","errorMessage":"${result?.message || 'Core function failed to parse PRD or returned unexpected result.'}","messagePattern":"\\$\\{result\\?\\.message \\|\\| 'Core function failed to parse PRD or returned unexpected result\\.'\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/parse-prd.js","lineNumber":195,"sourceCode":"\t\t\tlogWrapper.success(successMsg);\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {\n\t\t\t\t\tmessage: successMsg,\n\t\t\t\t\toutputPath: result.tasksPath,\n\t\t\t\t\ttelemetryData: result.telemetryData,\n\t\t\t\t\ttagInfo: result.tagInfo\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\t// Handle case where core function didn't return expected success structure\n\t\t\tlogWrapper.error(\n\t\t\t\t'Core parsePRD function did not return a successful structure.'\n\t\t\t);\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:\n\t\t\t\t\t\tresult?.message ||\n\t\t\t\t\t\t'Core function failed to parse PRD or returned unexpected result.'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\tlogWrapper.error(`Error executing core parsePRD: ${error.message}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'PARSE_PRD_CORE_ERROR',\n\t\t\t\tmessage: error.message || 'Unknown error parsing PRD'\n\t\t\t}\n\t\t};\n\t} finally {\n\t\tif (!wasSilent && isSilentMode()) {\n\t\t\tdisableSilentMode();","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/parse-prd.js#L177-L213","documentation":"After invoking the core parsePRD, the wrapper checks for result.success (parse-prd.js:187-201). If the core function returns without a success flag — a failure structure, an unexpected shape, or undefined — the wrapper reports CORE_FUNCTION_ERROR, preferring the core function's own `message` and falling back to a generic explanation. It signals the PRD parsing pipeline itself reported failure rather than an argument/filesystem problem.","triggerScenarios":"Core parsePRD resolves with { success: false, message } (e.g. AI provider failure, no tasks generated, force/append conflict handling) or returns an unexpected structure (null/undefined/partial result).","commonSituations":"Missing or invalid AI API keys so the core generation fails; the PRD produced zero parseable tasks; a version mismatch where the core parsePRD returns a shape this wrapper doesn't recognize; an existing tasks.json without --force/--append causing the core function to decline overwriting.","solutions":["Read `error.message` in the response — it carries the core function's own failure message when available.","If it mentions existing tasks, re-run with force: true (overwrite) or append: true (merge).","Verify AI provider credentials/environment (API keys) are available to the MCP server process.","Confirm package versions of the MCP server and scripts/core are in sync, since shape mismatches produce the generic fallback message.","Inspect the PRD content — empty or non-requirements documents can yield a failed parse."],"exampleFix":"// before\nawait parsePRDDirect({ projectRoot, input: prd }, log);\n// CORE_FUNCTION_ERROR: Task file already exists...\n\n// after — explicitly choose overwrite or append\nawait parsePRDDirect({ projectRoot, input: prd, force: true }, log);","handlingStrategy":"try-catch","validationCode":"if (!process.env.ANTHROPIC_API_KEY && !process.env.PERPLEXITY_API_KEY) {\n  console.warn('No AI provider keys detected; parse_prd core may fail.');\n}\nconst fs = require('fs');\nif (fs.existsSync(tasksOutputPath) && !force && !append) {\n  console.warn('tasks.json exists; pass force or append to avoid core refusal.');\n}","typeGuard":"function isCoreFunctionError(result) {\n  return result != null && result.success === false && result.error?.code === 'CORE_FUNCTION_ERROR';\n}","tryCatchPattern":"const result = await parsePRDDirect({ projectRoot, input, force, append }, log);\nif (isCoreFunctionError(result)) {\n  console.error('parse-prd core failed:', result.error.message);\n  // act on the core message: credentials, existing tasks.json (force/append), PRD content\n}","preventionTips":["Ensure AI provider API keys are set in the MCP server's environment.","Pass force: true or append: true when tasks.json already exists.","Keep the MCP server and core scripts versions in sync.","Sanity-check the PRD is non-empty and contains real requirements.","Prefer the core function's own message (error.message) over the generic fallback when debugging."],"tags":["mcp","core-function","prd","wrapped-error"],"backgroundTag":"core-function-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}