eyaltoledano/claude-task-master · error
Task ${taskId} not found
Error message
Task ${taskId} not found What it means
After loading a valid tasks array, expandTask() searches for a task whose id equals parseInt(taskId, 10). If no task matches, it throws 'Task <id> not found' rather than expanding a nonexistent item.
Source
Thrown at scripts/modules/task-manager/expand-task.js:103
report
});
// If remote handled it, return the result
if (remoteResult) {
return remoteResult;
}
// Otherwise fall through to file-based logic below
// --- End BRIDGE ---
// --- Task Loading/Filtering (Unchanged) ---
logger.info(`Reading tasks from ${tasksPath}`);
const data = readJSON(tasksPath, projectRoot, tag);
if (!data || !data.tasks)
throw new Error(`Invalid tasks data in ${tasksPath}`);
const taskIndex = data.tasks.findIndex(
(t) => t.id === parseInt(taskId, 10)
);
if (taskIndex === -1) throw new Error(`Task ${taskId} not found`);
const task = data.tasks[taskIndex];
logger.info(
`Expanding task ${taskId}: ${task.title}${useResearch ? ' with research' : ''}`
);
// --- End Task Loading/Filtering ---
// --- Handle Force Flag: Clear existing subtasks if force=true ---
if (force && Array.isArray(task.subtasks) && task.subtasks.length > 0) {
logger.info(
`Force flag set. Clearing existing ${task.subtasks.length} subtasks for task ${taskId}.`
);
task.subtasks = []; // Clear existing subtasks
}
// --- End Force Flag Handling ---
// --- Context Gathering ---
let gatheredContext = '';
try {View on GitHub (pinned to c0c98d367c)
Solutions
- Run `task-master list` (or read tasks.json) to confirm the exact top-level task ID, then retry with that numeric ID.
- If you meant a subtask, use expand-task with the parent task ID — subtask expansion is handled differently.
- Check the active tag; switch to the tag containing the task (task-master use-tag <tag>).
Example fix
// before
await expandTask('42'); // no task 42
// after
await expandTask('12'); // verified via task-master list Defensive patterns
Strategy: validation
Validate before calling
const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
const numericId = parseInt(taskId, 10);
if (!data.tasks.some((t) => t.id === numericId)) {
throw new Error(`Task ${numericId} does not exist; use task-master list to find valid IDs`);
} Type guard
function taskExists(tasks, id) {
return tasks.some((t) => t.id === Number(id));
} Try / catch
try {
await expandTask(taskId, context);
} catch (err) {
if (/Task \d+ not found/.test(err.message)) {
console.error(`No task with id ${taskId} — check 'task-master list' and the active tag.`);
} else throw err;
} Prevention
- List tasks and copy exact IDs before expanding.
- Remember expandTask takes top-level numeric IDs, not subtask IDs like 5.2.
- Check the active tag matches where the task lives.
When it happens
Trigger: Calling expandTask with an ID that does not exist in the current tasks file — a typo, an out-of-range ID, a subtask-style ID like '1.2' (parseInt yields 1 unless exact match exists... here strictly integer matching), or an ID belonging to a different tag's file.
Common situations: Referring to a subtask ID (e.g. 5.2) where expandTask expects a top-level task ID; task list changed after deletion/next renumbering; querying the wrong tag; ID from a stale complexity report or console output.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Prompt must be a non-empty string
- Prompt cannot be empty or only whitespace
- Task ${taskId} not found
- Task ${taskId} not found
- Parent task with ID ${parentIdNum} not found
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/793f4bad0b20550d.
Report an issue: GitHub.