{"record":{"id":"31ca281aa4661f00","repo":"eyaltoledano/claude-task-master","slug":"core-function-error-31ca28","errorCode":"CORE_FUNCTION_ERROR","errorMessage":"${error.message || 'Failed to find next task'}","messagePattern":"\\$\\{error\\.message \\|\\| 'Failed to find next task'\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/next-task.js","lineNumber":117,"sourceCode":"\t\t\t\t`Successfully found next task ${nextTask.id}: ${nextTask.title}. Is subtask: ${isSubtask}`\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {\n\t\t\t\t\tnextTask,\n\t\t\t\t\tisSubtask,\n\t\t\t\t\tnextSteps: `When ready to work on the ${taskOrSubtask}, use set-status to set the status to \"in progress\" ${additionalAdvice}`\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\tdisableSilentMode();\n\n\t\t\tlog.error(`Error finding next 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 find next task'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t};\n\n\t// Use the caching utility\n\ttry {\n\t\tconst result = await coreNextTaskAction();\n\t\tlog.info('nextTaskDirect completed.');\n\t\treturn result;\n\t} catch (error) {\n\t\tlog.error(`Unexpected error during nextTask: ${error.message}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'UNEXPECTED_ERROR',\n\t\t\t\tmessage: error.message","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/next-task.js#L99-L135","documentation":"coreNextTaskAction wraps the core `findNextTask` logic in a try/catch (next-task.js:109-121). Any exception thrown while reading the complexity report or computing the next task is normalized to a CORE_FUNCTION_ERROR with the underlying error message. It is a pass-through of an internal failure, not a validation error.","triggerScenarios":"readComplexityReport throws on a corrupted or unreadable complexity report at `reportPath`; findNextTask throws on malformed task objects (e.g. tasks missing `status` or `dependencies` fields of the wrong type); any unexpected exception inside the core action after silent mode was enabled.","commonSituations":"A stale or hand-edited complexity-report.json whose structure changed; tasks.json entries with corrupted dependency lists (missing referenced task IDs of wrong types); version drift where the scripts layer expects fields the tasks file doesn't have.","solutions":["Read the inner `error.message` in the response — it names the actual failing operation.","If it mentions the complexity report, delete or regenerate report/complexity-report.json (via analyze-complexity) or pass a valid `reportPath`.","If it mentions task data, run validate/update on your tasks.json to repair malformed task or dependency entries.","Retry after fixing; the error disables silent mode before returning, so normal logging is restored."],"exampleFix":"// before\nnextTaskDirect({ tasksJsonPath, reportPath: '/proj/report/complexity-report.json' }, log);\n// -> CORE_FUNCTION_ERROR: could not parse complexity report\n\n// after — regenerate or omit a broken report\nfs.rmSync('/proj/report/complexity-report.json');\nnextTaskDirect({ tasksJsonPath }, log); // complexity report is optional","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nfunction complexityReportOk(p) {\n  if (!p) return true; // optional\n  if (!fs.existsSync(p)) return false;\n  try { return typeof JSON.parse(fs.readFileSync(p, 'utf8')) === 'object'; }\n  catch { return false; }\n}","typeGuard":"function isCoreFunctionError(result) {\n  return result != null && result.success === false && result.error?.code === 'CORE_FUNCTION_ERROR';\n}","tryCatchPattern":"const result = await nextTaskDirect({ tasksJsonPath, reportPath }, log);\nif (isCoreFunctionError(result)) {\n  console.error('next-task core failure:', result.error.message);\n  // regenerate complexity report or repair tasks.json based on message, then retry\n}","preventionTips":["Regenerate complexity-report.json after task changes instead of hand-editing it.","Pass no reportPath if you do not need complexity data — it is optional.","Keep tasks.json schema-valid (status, dependencies arrays).","Log the inner error.message — it identifies the failing core operation."],"tags":["mcp","core-function","wrapped-error","complexity-report"],"backgroundTag":"core-function-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}