ruvnet/ruflo · error
Task ${taskId} not found
Error message
Task ${taskId} not found What it means
This comes from the mock task repository built by the testing mock-factory: execute(taskId) looks the id up in the mock in-memory tasks map, which is populated only by the same mock submit/create calls, and throws for unknown ids. It faithfully mimics a real repository not-found behavior.
Source
Thrown at v3/@claude-flow/testing/src/helpers/mock-factory.ts:342
mock.create.mockImplementation(async (definition: TaskDefinition) => {
const task: Task = {
id: `task-${++taskCounter}`,
name: definition.name,
type: definition.type,
status: 'pending',
payload: definition.payload,
priority: definition.priority ?? 50,
createdAt: new Date(),
};
tasks.set(task.id, task);
return task;
});
mock.execute.mockImplementation(async (taskId: string) => {
const task = tasks.get(taskId);
if (!task) {
throw new Error(`Task ${taskId} not found`);
}
task.status = 'running';
task.startedAt = new Date();
// Simulate execution
await new Promise(resolve => setTimeout(resolve, 10));
task.status = 'completed';
task.completedAt = new Date();
return {
taskId,
success: true,
duration: task.completedAt.getTime() - task.startedAt.getTime(),
};
});
mock.cancel.mockImplementation(async (taskId: string) => {View on GitHub (pinned to fa13ee4ad6)
Solutions
- Create the task through the mock first and use the id it returns
- Derive ids from the created task object rather than literals
- When testing the error path intentionally, wrap the call in a rejects assertion
Example fix
// before
await mock.execute('task_1'); // throws: never created on this mock
// after
const task = await mock.submit(definition);
await mock.execute(task.id); Defensive patterns
Strategy: validation
Validate before calling
// Track ids you created on the mock
const createdIds = new Set<string>();
async function submitAndTrack(def: TaskDefinitionInput) {
const t = await mock.submit(def);
createdIds.add(t.id);
return t;
}
if (!createdIds.has(taskId)) {
throw new Error(`Unknown mock task ${taskId}; create it with mock.submit first`);
}
await mock.execute(taskId); Type guard
function isKnownMockTask(taskId: string, created: Set<string>): taskId is string {
return created.has(taskId);
} Try / catch
try {
await mock.execute(taskId);
} catch (err) {
if (err instanceof Error && err.message.endsWith('not found')) {
const task = await mock.submit(definition); // recreate on this mock, then run
return mock.execute(task.id);
}
throw err;
} Prevention
- Never hardcode mock task ids; always chain from the submit return value
- Re-create mock state in beforeEach rather than relying on cross-test ordering
- Assert intended failures with a rejects-toThrow assertion on the not-found message
When it happens
Trigger: Calling mock.execute('task_999') without first calling the mock submit or create for that id; mixing ids from a real repository or another mock instance; a test deleting from the map and then executing.
Common situations: Hardcoded task ids reused across tests while the mock is reset in beforeEach; passing a task definition where the id is expected; assuming the mock accepts any id.
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
- Mock was called with unexpected arguments: ${JSON.stringify(
- Invalid token
- hexToBytes: odd-length hex string
- SSRF guard: only HTTPS URLs are permitted, got ${parsed.prot
- SSRF guard: private/loopback host rejected — ${host}
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/fdc0415124a853a2.
Report an issue: GitHub.