eyaltoledano/claude-task-master · error
UNEXPECTED_ERROR
UNEXPECTED_ERROR
Error message
${error.message} What it means
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.
Source
Thrown at mcp-server/src/core/direct-functions/next-task.js:134
error: {
code: 'CORE_FUNCTION_ERROR',
message: error.message || 'Failed to find next task'
}
};
}
};
// Use the caching utility
try {
const result = await coreNextTaskAction();
log.info('nextTaskDirect completed.');
return result;
} catch (error) {
log.error(`Unexpected error during nextTask: ${error.message}`);
return {
success: false,
error: {
code: 'UNEXPECTED_ERROR',
message: error.message
}
};
}
}
View on GitHub (pinned to c0c98d367c)
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.
Example fix
// before
await nextTaskDirect(null, log); // UNEXPECTED_ERROR
// after
const result = await nextTaskDirect({ tasksJsonPath: tasksPath, projectRoot }, log);
if (!result.success) console.error(result.error.code, result.error.message); Defensive patterns
Strategy: try-catch
Validate before calling
if (args == null || typeof args !== 'object') throw new TypeError('nextTaskDirect args must be an object');
if (typeof log?.info !== 'function' || typeof log?.error !== 'function') throw new TypeError('log must implement info/error'); Type guard
function isUnexpectedError(result) {
return result != null && result.success === false && result.error?.code === 'UNEXPECTED_ERROR';
} Try / catch
try {
const result = await nextTaskDirect(args ?? {}, log);
if (isUnexpectedError(result)) console.error('unexpected:', result.error.message);
} catch (e) {
console.error('nextTaskDirect threw synchronously:', e.message);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/536f29e8b8100918.
Report an issue: GitHub.