{"record":{"id":"8fce60938da0be89","repo":"eyaltoledano/claude-task-master","slug":"prompt-cannot-be-empty-unless-metadata-is-provided-8fce60","errorCode":null,"errorMessage":"Prompt cannot be empty unless metadata is provided for update.","messagePattern":"Prompt cannot be empty unless metadata is provided for update\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":84,"sourceCode":"\t\tmetadata\n\t} = context;\n\tconst { report, isMCP } = createBridgeLogger(mcpLog, session);\n\n\ttry {\n\t\treport('info', `Updating single task ${taskId} with prompt: \"${prompt}\"`);\n\n\t\t// --- Input Validations ---\n\t\t// Note: taskId can be a number (1), string with dot (1.2), or display ID (HAM-123)\n\t\t// So we don't validate it as strictly anymore\n\t\tif (taskId === null || taskId === undefined || String(taskId).trim() === '')\n\t\t\tthrow new Error('Task ID cannot be empty.');\n\n\t\t// Allow metadata-only updates (prompt can be empty if metadata is provided)\n\t\tif (\n\t\t\t(!prompt || typeof prompt !== 'string' || prompt.trim() === '') &&\n\t\t\t!metadata\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'Prompt cannot be empty unless metadata is provided for update.'\n\t\t\t);\n\t\t}\n\n\t\t// Determine project root first (needed for API key checks)\n\t\tconst projectRoot = providedProjectRoot || findProjectRoot();\n\t\tif (!projectRoot) {\n\t\t\tthrow new Error('Could not determine project root directory');\n\t\t}\n\n\t\tif (useResearch && !isApiKeySet('perplexity', session)) {\n\t\t\treport(\n\t\t\t\t'warn',\n\t\t\t\t'Perplexity research requested but API key not set. Falling back.'\n\t\t\t);\n\t\t\tif (outputFormat === 'text')\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.yellow('Perplexity AI not available. Falling back to main AI.')","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L66-L102","documentation":"updateTaskById() requires a non-empty prompt string unless a metadata object is supplied. This allows metadata-only updates while rejecting calls that would give the AI nothing to act on. The error fires when both prompt is empty/not a string and metadata is absent.","triggerScenarios":"Calling updateTaskById(5, '') or updateTaskById(5, '   ') with no metadata argument; calling updateTaskById(5) relying on defaults; passing a non-string (e.g., an object) as prompt without metadata.","commonSituations":"Forgetting to pass the update instructions when scripting; whitespace-only prompt from trimmed user input; intending a metadata-only update but forgetting to pass the metadata object.","solutions":["Provide a non-empty prompt string describing the update","If you only want to change metadata, pass a metadata object instead of a prompt","Validate/trim user-supplied prompt text before calling"],"exampleFix":"// before\nawait updateTaskById(5, ''); // throws\n// after\nawait updateTaskById(5, '', { priority: 'high' }); // metadata-only update\n// or\nawait updateTaskById(5, 'Add error handling to the parser');","handlingStrategy":"validation","validationCode":"function assertUpdateInput(prompt, metadata) {\n  const hasPrompt = typeof prompt === 'string' && prompt.trim() !== '';\n  const hasMetadata = metadata !== null && metadata !== undefined;\n  if (!hasPrompt && !hasMetadata) {\n    throw new Error('Provide a prompt or metadata for the update');\n  }\n}","typeGuard":"function hasUpdateInput(prompt, metadata) {\n  return (typeof prompt === 'string' && prompt.trim() !== '') || metadata != null;\n}","tryCatchPattern":"try {\n  await updateTaskById(5, prompt, metadata);\n} catch (err) {\n  if (err.message.includes('Prompt cannot be empty')) {\n    console.error('Pass a non-empty prompt, or a metadata object for metadata-only updates');\n  } else throw err;\n}","preventionTips":["Trim and check user-supplied prompt text before calling","Use the metadata parameter explicitly for metadata-only updates","Never pass raw, unvalidated CLI input as prompt","Document in scripts that either prompt or metadata is mandatory"],"tags":["validation","input","prompt","task-management"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}