{"record":{"id":"6f63b333f3794256","repo":"eyaltoledano/claude-task-master","slug":"prompt-cannot-be-empty-unless-metadata-is-provided","errorCode":null,"errorMessage":"Prompt cannot be empty unless metadata is provided. Please provide context for the subtask update or metadata to merge.","messagePattern":"Prompt cannot be empty unless metadata is provided\\. Please provide context for the subtask update or metadata to merge\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-subtask-by-id.js","lineNumber":85,"sourceCode":"\t\t\tlogFn(level, ...args);\n\t\t}\n\t};\n\n\tlet loadingIndicator = null;\n\n\ttry {\n\t\treport('info', `Updating subtask ${subtaskId} with prompt: \"${prompt}\"`);\n\n\t\t// Basic validation - ID must be present\n\t\tif (!subtaskId || typeof subtaskId !== 'string') {\n\t\t\tthrow new Error('Subtask ID cannot be empty.');\n\t\t}\n\t\t// Allow metadata-only updates (no prompt required 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. Please provide context for the subtask update or metadata to merge.'\n\t\t\t);\n\t\t}\n\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\t// --- BRIDGE: Try remote update first (API storage) ---\n\t\t// In API storage, subtask IDs like \"HAM-2611\" are just regular task IDs\n\t\t// So update-subtask and update-task work identically\n\t\tconst remoteResult = await tryUpdateViaRemote({\n\t\t\ttaskId: subtaskId,\n\t\t\tprompt,\n\t\t\tprojectRoot,\n\t\t\ttag,\n\t\t\tappendMode: true, // Subtask updates are always append mode","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-subtask-by-id.js#L67-L103","documentation":"The update prompt may be omitted only when a metadata object is supplied for a metadata-only merge. If both prompt and metadata are missing/empty, this error is thrown.","triggerScenarios":"Calling updateSubtaskById with an empty/whitespace prompt and no metadata; MCP clients sending only the subtaskId.","commonSituations":"Automations that send an empty prompt, users invoking the CLI update-subtask command without a prompt argument while expecting defaults.","solutions":["Provide a non-empty prompt describing the update","Pass a metadata object instead if you only want field merges","Ensure the prompt string is not just whitespace; trim and check length before calling"],"exampleFix":"// before\nawait updateSubtaskById('5.2', '   ', options); // blank prompt, no metadata\n// after\nconst prompt = buildPrompt();\nawait updateSubtaskById('5.2', prompt.trim() ? prompt : null, { ...options, metadata: { notes: 'sync fields' } });","handlingStrategy":"validation","validationCode":"if ((!prompt || typeof prompt !== 'string' || prompt.trim() === '') && !metadata) {\n  throw new Error('Provide a non-empty prompt or a metadata object');\n}","typeGuard":"function hasUpdateInput(prompt, metadata) {\n  return (typeof prompt === 'string' && prompt.trim() !== '') || (metadata !== null && typeof metadata === 'object');\n}","tryCatchPattern":"try {\n  await updateSubtaskById(subtaskId, prompt, options);\n} catch (err) {\n  if (err.message.startsWith('Prompt cannot be empty')) {\n    console.error('Supply a prompt or pass metadata for a metadata-only update');\n  } else throw err;\n}","preventionTips":["Check prompt.trim().length before calling","Use metadata for field-only merges instead of an empty prompt","Validate CLI/MCP arguments map to non-empty strings"],"tags":["validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}