{"record":{"id":"95912cdf763e1cb3","repo":"eyaltoledano/claude-task-master","slug":"failed-to-load-prompt-template-error-message","errorCode":null,"errorMessage":"Failed to load prompt template: ${error.message}","messagePattern":"Failed to load prompt template: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":342,"sourceCode":"\t\t\t\tpromptParams,\n\t\t\t\tvariantKey\n\t\t\t);\n\t\t\treport(\n\t\t\t\t'info',\n\t\t\t\t`Prompt result type: ${typeof promptResult}, keys: ${promptResult ? Object.keys(promptResult).join(', ') : 'null'}`\n\t\t\t);\n\n\t\t\t// Extract prompts - loadPrompt returns { systemPrompt, userPrompt, metadata }\n\t\t\tsystemPrompt = promptResult.systemPrompt;\n\t\t\tuserPrompt = promptResult.userPrompt;\n\n\t\t\treport(\n\t\t\t\t'info',\n\t\t\t\t`Loaded prompts - systemPrompt length: ${systemPrompt?.length}, userPrompt length: ${userPrompt?.length}`\n\t\t\t);\n\t\t} catch (error) {\n\t\t\treport('error', `Failed to load prompt template: ${error.message}`);\n\t\t\tthrow new Error(`Failed to load prompt template: ${error.message}`);\n\t\t}\n\n\t\t// If prompts are still not set, throw an error\n\t\tif (!systemPrompt || !userPrompt) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to load prompts: systemPrompt=${!!systemPrompt}, userPrompt=${!!userPrompt}`\n\t\t\t);\n\t\t}\n\t\t// --- End Build Prompts ---\n\n\t\tlet loadingIndicator = null;\n\t\tlet aiServiceResponse = null;\n\n\t\tif (!isMCP && outputFormat === 'text') {\n\t\t\tloadingIndicator = startLoadingIndicator(\n\t\t\t\tuseResearch ? 'Updating task with research...\\n' : 'Updating task...\\n'\n\t\t\t);\n\t\t}","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L324-L360","documentation":"updateTaskById() loads prompt templates (via promptManager/getPrompt) to build the systemPrompt and userPrompt sent to the AI. If template loading throws, the error is logged and rethrown wrapped as 'Failed to load prompt template: <original message>', preserving the underlying cause.","triggerScenarios":"Missing or renamed prompt template files in the prompts/assets directory (broken install or partial copy); a customized template file with invalid syntax that the template engine cannot parse; permission errors reading the template path; version mismatch where code expects a template key the installed assets do not define.","commonSituations":"Partial npm installs or corrupted node_modules / global installs; users overriding prompt directories with bad paths; upgrading Task Master without updating customized prompt files; running from a packaged binary missing asset files.","solutions":["Read the wrapped inner message to identify the root cause (file not found vs parse error)","Reinstall task-master (npm ci / reinstall globally) to restore intact prompt template assets","If templates were customized, fix the template syntax or restore the originals","Verify file permissions on the prompts directory and that the configured template path is correct","Check for a version mismatch and align customized templates with the installed version"],"exampleFix":"// before\n// prompts/update-task.txt deleted or malformed -> throws\n// after\nnpm ci  # or: npm install -g task-master-ai@latest  # restores template assets\n// then retry:\nawait updateTaskById(5, prompt);","handlingStrategy":"try-catch","validationCode":"import fs from 'fs';\nfunction assertTemplateAssets(promptsDir) {\n  if (!fs.existsSync(promptsDir) || fs.readdirSync(promptsDir).length === 0) {\n    throw new Error(`Prompt templates missing at ${promptsDir}; reinstall task-master`);\n  }\n}","typeGuard":"function templatesAvailable(promptsDir) {\n  return fs.existsSync(promptsDir) && fs.readdirSync(promptsDir).length > 0;\n}","tryCatchPattern":"try {\n  await updateTaskById(5, prompt);\n} catch (err) {\n  if (err.message.startsWith('Failed to load prompt template')) {\n    console.error('Root cause:', err.message); // wrapped inner message\n    console.error('Reinstall task-master or restore/fix the custom template file');\n  } else throw err;\n}","preventionTips":["Keep prompt template assets intact — avoid partial installs and manual deletion inside the package","If customizing templates, validate their syntax after every edit","Pin and align versions when templates are overridden or vendored","Check file read permissions on the prompts directory in CI/containers","Log the inner error message (it is preserved after the prefix) to diagnose the real cause"],"tags":["templates","prompts","ai","task-management","filesystem"],"backgroundTag":"prompt-template-load-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}