eyaltoledano/claude-task-master · error
Task with ID ${taskId} not found in tag '${tag}'
Error message
Task with ID ${taskId} not found in tag '${tag}' What it means
removeTask() throws this when a main task ID cannot be found in the parsed task list for the current tag. After parsing the ID to an integer it uses findIndex over data.tasks; a -1 result means no task with that numeric id exists under the active tag. This is a data lookup failure, not a crash: the ID is either wrong, belongs to a different tag, or the task file is missing that entry.
Source
Thrown at scripts/modules/task-manager/remove-task.js:105
const removedSubtask = {
...parentTask.subtasks[subtaskIndex],
parentTaskId: parentTaskId
};
results.removedTasks.push(removedSubtask);
// Remove the subtask from the parent
parentTask.subtasks.splice(subtaskIndex, 1);
results.messages.push(
`Successfully removed subtask ${taskId} from tag '${tag}'`
);
}
// Handle main task removal
else {
const taskIdNum = parseInt(taskId, 10);
const taskIndex = tasks.findIndex((t) => t.id === taskIdNum);
if (taskIndex === -1) {
throw new Error(`Task with ID ${taskId} not found in tag '${tag}'`);
}
// Store the task info before removal
const removedTask = tasks[taskIndex];
results.removedTasks.push(removedTask);
tasksToDeleteFiles.push(taskIdNum); // Add to list for file deletion
// Remove the task from the main array
tasks.splice(taskIndex, 1);
results.messages.push(
`Successfully removed task ${taskId} from tag '${tag}'`
);
}
} catch (innerError) {
// Catch errors specific to processing *this* ID
const errorMsg = `Error processing ID ${taskId}: ${innerError.message}`;
results.errors.push(errorMsg);View on GitHub (pinned to c0c98d367c)
Solutions
- List tasks in the active tag (task-master list) and confirm the exact ID before calling removeTask.
- Check which tag is active (task-master tags) and either switch tags or pass context.tag pointing at the tag containing the task.
- If the ID contains non-numeric characters, strip them first so parseInt resolves the intended number.
- Wrap the call in try/catch and surface a friendly 'task not found' message to the user instead of a stack trace.
Example fix
// before
await removeTask('5', { tag: 'master' });
// after
const tasks = readJSON(tasksPath, projectRoot, 'master').tasks;
if (tasks.some((t) => t.id === 5)) {
await removeTask('5', { tag: 'master' });
} else {
console.log('Task 5 does not exist in master; check `task-master list`');
} Defensive patterns
Strategy: validation
Validate before calling
const tasks = readJSON(tasksPath, projectRoot, tag)?.tasks || [];
const id = parseInt(taskId, 10);
if (!tasks.some((t) => t.id === id)) {
throw new Error(`Task ${id} not found in tag '${tag}' — run 'task-master list' first`);
}
await removeTask(taskId, { tag }); Type guard
function taskExistsIn(tasks, taskId) {
const id = parseInt(taskId, 10);
return Number.isInteger(id) && tasks.some((t) => t.id === id);
} Try / catch
try {
await removeTask(taskId, { tag });
} catch (err) {
if (err.message.includes('not found in tag')) {
console.error(`Task ${taskId} does not exist in tag '${tag}'. Available: ${listIds()}`);
} else throw err;
} Prevention
- Always list tasks in the active tag before removing by ID
- Check the active tag with 'task-master tags' in multi-tag workspaces
- Sanitize ID strings so parseInt resolves the intended number
- Cache task IDs only for a single script run; re-read tasks.json each time
When it happens
Trigger: Calling removeTask(taskId) (or tasks.remove) with an ID that does not exist in the tasks.json for the active tag, e.g. removeTask('5') when only tasks 1-4 exist, passing a non-numeric string that parseInt maps to a wrong number (parseInt('5abc') === 5), or removing while a tag other than the one containing the task is active.
Common situations: Stale IDs after regenerating task lists, working in a multi-tag workspace where the task exists in 'feature-x' but not 'master', typos in scripts/automation calling removeTask, or tasks.json edited manually and an entry deleted.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Task with ID ${taskId} not found
- TASK_NOT_FOUND
- Template "${templateName}" not found
- Task ${taskId} not found
- Task ${taskId} not found
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/b6e19eac0436043f.
Report an issue: GitHub.