{"record":{"id":"f9f21b1a90098be9","repo":"eyaltoledano/claude-task-master","slug":"failed-to-load-prompts-systemprompt-systempro","errorCode":null,"errorMessage":"Failed to load prompts: systemPrompt=${!!systemPrompt}, userPrompt=${!!userPrompt}","messagePattern":"Failed to load prompts: systemPrompt=(.+?), userPrompt=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":347,"sourceCode":"\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}\n\n\t\ttry {\n\t\t\tconst serviceRole = useResearch ? 'research' : 'main';\n\n\t\t\tif (appendMode) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L329-L365","documentation":"updateTaskById loads prompt templates to build the systemPrompt and userPrompt sent to the AI service. If either prompt is still falsy after the template loading/override logic completes, it throws with a boolean snapshot of which prompts are missing. This is a guard against sending a malformed request to the AI provider.","triggerScenarios":"Calling updateTaskById with --prompt/--research flow where the prompt template file fails to resolve silently, or prompt overrides produce an empty string, so systemPrompt or userPrompt remains unset after the 'Build Prompts' section.","commonSituations":"Missing or corrupted prompt template files in the installation, a custom .taskmaster template path pointing to an empty file, or an env/config option (e.g. custom template directory) overriding the prompt with undefined.","solutions":["Verify the built-in prompt template files exist and are readable in scripts/modules/ai-prompts (or configured template dir)","Reinstall or repair the package to restore default prompt templates","If overriding prompts via config/env, ensure both system and user prompt overrides are non-empty strings","Check the preceding 'Failed to load prompt template' log/report output for the underlying cause"],"exampleFix":"// before\nconst { systemPrompt, userPrompt } = loadPrompts(customPath); // customPath empty file\n// after\nconst { systemPrompt, userPrompt } = loadPrompts(); // use default templates, or fix custom file content","handlingStrategy":"try-catch","validationCode":"const { systemPrompt, userPrompt } = buildPrompts();\nif (!systemPrompt || !userPrompt) throw new Error('Prompt templates missing; reinstall or fix template config');","typeGuard":"const hasPrompts = (p) => typeof p?.systemPrompt === 'string' && p.systemPrompt.length > 0 && typeof p?.userPrompt === 'string' && p.userPrompt.length > 0;","tryCatchPattern":"try {\n  await updateTaskById(...);\n} catch (e) {\n  if (String(e.message).startsWith('Failed to load prompts')) {\n    // restore/repair prompt templates, then retry\n  } else throw e;\n}","preventionTips":["Do not point prompt-template config at empty or non-existent files","Reinstall the package if templates were deleted","Keep custom prompt overrides as non-empty strings","Read the earlier 'Failed to load prompt template' message to fix the root cause"],"tags":["ai","prompts","template-loading","input-validation"],"backgroundTag":"prompt-template-load-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}