eyaltoledano/claude-task-master · error
Task ID cannot be empty.
Error message
Task ID cannot be empty.
What it means
updateTaskById() performs early input validation and rejects calls where taskId is null, undefined, or an empty/whitespace-only string. The task ID is required to locate the task to update, so the function fails fast before any I/O.
Source
Thrown at scripts/modules/task-manager/update-task-by-id.js:77
appendMode = false
) {
const {
session,
mcpLog,
projectRoot: providedProjectRoot,
tag,
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)) {View on GitHub (pinned to c0c98d367c)
Solutions
- Pass a valid non-empty task ID (e.g., 5, '5', 'HAM-123') as the first argument
- If the ID comes from a CLI flag or script, check it is populated before calling
- Fix argument ordering — ensure the prompt is the second parameter, not shifted into the ID position
Example fix
// before
await updateTaskById(taskIdFromFlag, prompt); // may be ''
// after
if (!taskIdFromFlag || String(taskIdFromFlag).trim() === '') {
throw new Error('--id is required');
}
await updateTaskById(taskIdFromFlag, prompt); Defensive patterns
Strategy: validation
Validate before calling
function assertTaskId(taskId) {
if (taskId === null || taskId === undefined || String(taskId).trim() === '') {
throw new Error('taskId is required');
}
} Type guard
function isValidTaskId(taskId) {
return taskId !== null && taskId !== undefined && String(taskId).trim() !== '';
} Try / catch
try {
await updateTaskById(taskId, prompt);
} catch (err) {
if (err.message === 'Task ID cannot be empty.') {
console.error('Provide a task ID, e.g. task-master update --id=5 --prompt="..."');
} else throw err;
} Prevention
- Check CLI args/flags for empty strings before calling API functions
- Validate that upstream parsing actually produced an ID
- Keep argument order consistent: (taskId, prompt, options)
- Fail fast in scripts with explicit ID checks
When it happens
Trigger: Calling updateTaskById(null, prompt), updateTaskById('', prompt), or updateTaskById(' ', prompt); passing an uninitialized variable as taskId from upstream parsing that produced no value.
Common situations: CLI flag parsing yielding an empty string when the --id flag is omitted; a script variable that was never assigned; pipeline output that returned empty instead of an ID; refactors that changed argument order so prompt lands in the taskId slot.
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
- Prompt cannot be empty unless metadata is provided for updat
- 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/daeae4a9543fa134.
Report an issue: GitHub.