{"record":{"id":"daeae4a9543fa134","repo":"eyaltoledano/claude-task-master","slug":"task-id-cannot-be-empty","errorCode":null,"errorMessage":"Task ID cannot be empty.","messagePattern":"Task ID cannot be empty\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":77,"sourceCode":"\tappendMode = false\n) {\n\tconst {\n\t\tsession,\n\t\tmcpLog,\n\t\tprojectRoot: providedProjectRoot,\n\t\ttag,\n\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)) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L59-L95","documentation":"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.","triggerScenarios":"Calling updateTaskById(null, prompt), updateTaskById('', prompt), or updateTaskById('   ', prompt); passing an uninitialized variable as taskId from upstream parsing that produced no value.","commonSituations":"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.","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"],"exampleFix":"// before\nawait updateTaskById(taskIdFromFlag, prompt); // may be ''\n// after\nif (!taskIdFromFlag || String(taskIdFromFlag).trim() === '') {\n  throw new Error('--id is required');\n}\nawait updateTaskById(taskIdFromFlag, prompt);","handlingStrategy":"validation","validationCode":"function assertTaskId(taskId) {\n  if (taskId === null || taskId === undefined || String(taskId).trim() === '') {\n    throw new Error('taskId is required');\n  }\n}","typeGuard":"function isValidTaskId(taskId) {\n  return taskId !== null && taskId !== undefined && String(taskId).trim() !== '';\n}","tryCatchPattern":"try {\n  await updateTaskById(taskId, prompt);\n} catch (err) {\n  if (err.message === 'Task ID cannot be empty.') {\n    console.error('Provide a task ID, e.g. task-master update --id=5 --prompt=\"...\"');\n  } else throw err;\n}","preventionTips":["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"],"tags":["validation","input","task-management"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}