eyaltoledano/claude-task-master · error
Prompt cannot be empty unless metadata is provided for updat
Error message
Prompt cannot be empty unless metadata is provided for update.
What it means
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.
Source
Thrown at scripts/modules/task-manager/update-task-by-id.js:84
metadata
} = context;
const { report, isMCP } = createBridgeLogger(mcpLog, session);
try {
report('info', `Updating single task ${taskId} with prompt: "${prompt}"`);
// --- Input Validations ---
// Note: taskId can be a number (1), string with dot (1.2), or display ID (HAM-123)
// So we don't validate it as strictly anymore
if (taskId === null || taskId === undefined || String(taskId).trim() === '')
throw new Error('Task ID cannot be empty.');
// Allow metadata-only updates (prompt can be empty if metadata is provided)
if (
(!prompt || typeof prompt !== 'string' || prompt.trim() === '') &&
!metadata
) {
throw new Error(
'Prompt cannot be empty unless metadata is provided for update.'
);
}
// Determine project root first (needed for API key checks)
const projectRoot = providedProjectRoot || findProjectRoot();
if (!projectRoot) {
throw new Error('Could not determine project root directory');
}
if (useResearch && !isApiKeySet('perplexity', session)) {
report(
'warn',
'Perplexity research requested but API key not set. Falling back.'
);
if (outputFormat === 'text')
console.log(
chalk.yellow('Perplexity AI not available. Falling back to main AI.')View on GitHub (pinned to c0c98d367c)
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
Example fix
// before
await updateTaskById(5, ''); // throws
// after
await updateTaskById(5, '', { priority: 'high' }); // metadata-only update
// or
await updateTaskById(5, 'Add error handling to the parser'); Defensive patterns
Strategy: validation
Validate before calling
function assertUpdateInput(prompt, metadata) {
const hasPrompt = typeof prompt === 'string' && prompt.trim() !== '';
const hasMetadata = metadata !== null && metadata !== undefined;
if (!hasPrompt && !hasMetadata) {
throw new Error('Provide a prompt or metadata for the update');
}
} Type guard
function hasUpdateInput(prompt, metadata) {
return (typeof prompt === 'string' && prompt.trim() !== '') || metadata != null;
} Try / catch
try {
await updateTaskById(5, prompt, metadata);
} catch (err) {
if (err.message.includes('Prompt cannot be empty')) {
console.error('Pass a non-empty prompt, or a metadata object for metadata-only updates');
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Task ID cannot be empty.
- Task description is required
- Task status is required
- No valid task IDs provided
- Invalid task ID format: ${invalidIds.join(', ')}. Expected n
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/8fce60938da0be89.
Report an issue: GitHub.