{"record":{"id":"6a5391d167bf2745","repo":"eyaltoledano/claude-task-master","slug":"direct-function-setup-error-6a5391","errorCode":"DIRECT_FUNCTION_SETUP_ERROR","errorMessage":"error.message || 'Unknown setup error'","messagePattern":"error\\.message \\|\\| 'Unknown setup error'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/update-subtask-by-id.js","lineNumber":157,"sourceCode":"\t\t\t\terror: {\n\t\t\t\t\tcode: 'UPDATE_SUBTASK_CORE_ERROR',\n\t\t\t\t\tmessage: error.message || 'Unknown error updating subtask'\n\t\t\t\t}\n\t\t\t};\n\t\t} finally {\n\t\t\tif (!wasSilent && isSilentMode()) {\n\t\t\t\tdisableSilentMode();\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tlogWrapper.error(\n\t\t\t`Setup error in updateSubtaskByIdDirect: ${error.message}`\n\t\t);\n\t\tif (isSilentMode()) disableSilentMode();\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'DIRECT_FUNCTION_SETUP_ERROR',\n\t\t\t\tmessage: error.message || 'Unknown setup error'\n\t\t\t}\n\t\t};\n\t}\n}\n","sourceCodeStart":139,"sourceCodeEnd":163,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/update-subtask-by-id.js#L139-L163","documentation":"Outer catch of updateSubtaskByIdDirect: exceptions thrown during function setup (before/around the main guarded block — logger initialization, silent-mode handling, argument destructuring) are returned as DIRECT_FUNCTION_SETUP_ERROR with error.message or 'Unknown setup error'. It signals infrastructure/wiring failure rather than a problem with the subtask update itself.","triggerScenarios":"Logger wrapper undefined due to a bad import, an exception while toggling silent mode, or a TypeError in setup code when required helpers are missing from the installed tm-core version.","commonSituations":"Partial npm install leaving mcp-server and tm-core out of sync; monkey-patched or custom logger passed to the direct function that throws on init.","solutions":["Inspect error.message in the returned result for the setup exception.","Reinstall/rebuild dependencies so @tm/core and the MCP server versions match.","Verify any custom logWrapper you pass implements the used methods (error, success, etc.).","Run the flow outside MCP (call the direct function in a script) to capture the full stack."],"exampleFix":"// before\nconst logWrapper = { info: console.log }; // missing .error\n// after\nconst logWrapper = getMcpLogger(session, 'update-subtask'); // full logger","handlingStrategy":"try-catch","validationCode":"import { getMcpLogger, isSilentMode, disableSilentMode } from '../tools/utils.js';\nfor (const [name, fn] of Object.entries({ getMcpLogger, isSilentMode, disableSilentMode })) {\n  if (typeof fn !== 'function') throw new Error(`Missing helper: ${name} — check @tm/core install`);\n}","typeGuard":"function isResultOk(r) { return r !== null && typeof r === 'object' && r.success === true; }","tryCatchPattern":"const res = await updateSubtaskByIdDirect(args);\nif (!res.success && res.error.code === 'DIRECT_FUNCTION_SETUP_ERROR') {\n  console.error('Setup failure:', res.error.message);\n  // reinstall deps / fix logger wiring, then retry once\n}","preventionTips":["Import logger and silent-mode helpers from a single vetted module","Smoke-test direct functions outside MCP after every dependency upgrade","Ensure any injected logWrapper implements the full interface (error, success, info)"],"tags":["mcp","setup","unhandled-exception"],"backgroundTag":"operation-failed-catch-all","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}