{"record":{"id":"536f29e8b8100918","repo":"eyaltoledano/claude-task-master","slug":"unexpected-error-536f29","errorCode":"UNEXPECTED_ERROR","errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/next-task.js","lineNumber":134,"sourceCode":"\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\n\t\t\t}\n\t\t};\n\t}\n}\n","sourceCodeStart":116,"sourceCodeEnd":140,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/next-task.js#L116-L140","documentation":"The outermost try/catch of nextTaskDirect (next-task.js:129-138) catches anything escaping the core action wrapper — e.g. a throw from the caching utility call itself or from logging — and returns UNEXPECTED_ERROR. Reaching this means the inner action's own error handling did not cover the failure.","triggerScenarios":"An exception thrown outside coreNextTaskAction's internal try/catch, such as a failure in the awaited wrapper machinery around line 126, a throwing logger, or a programming error (undefined function, bad args shape) that bypasses the guarded code path.","commonSituations":"Passing a non-object (null/undefined) as `args` so destructuring throws; a corrupted installation where an imported helper is missing; a logger implementation that throws on log.info/error.","solutions":["Inspect `error.message` in the response to identify the underlying exception.","Confirm you pass a plain args object: nextTaskDirect({}, log) at minimum, with tasksJsonPath set.","Reinstall/rebuild the package — missing or mismatched imports in scripts/modules can throw outside the guarded region.","Check your custom log object implements info/error without throwing."],"exampleFix":"// before\nawait nextTaskDirect(null, log); // UNEXPECTED_ERROR\n\n// after\nconst result = await nextTaskDirect({ tasksJsonPath: tasksPath, projectRoot }, log);\nif (!result.success) console.error(result.error.code, result.error.message);","handlingStrategy":"try-catch","validationCode":"if (args == null || typeof args !== 'object') throw new TypeError('nextTaskDirect args must be an object');\nif (typeof log?.info !== 'function' || typeof log?.error !== 'function') throw new TypeError('log must implement info/error');","typeGuard":"function isUnexpectedError(result) {\n  return result != null && result.success === false && result.error?.code === 'UNEXPECTED_ERROR';\n}","tryCatchPattern":"try {\n  const result = await nextTaskDirect(args ?? {}, log);\n  if (isUnexpectedError(result)) console.error('unexpected:', result.error.message);\n} catch (e) {\n  console.error('nextTaskDirect threw synchronously:', e.message);\n}","preventionTips":["Always pass a non-null args object, even if minimal.","Provide a standard logger object with info/error methods.","Keep the package installed/built consistently so imports resolve.","Treat UNEXPECTED_ERROR as a bug signal — capture error.message and report it."],"tags":["mcp","unexpected-error","wrapped-error"],"backgroundTag":"unexpected-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}