{"record":{"id":"698ddd4bc9fd8e49","repo":"ruvnet/ruflo","slug":"task-not-found-taskid-698ddd","errorCode":null,"errorMessage":"Task not found: ${taskId}","messagePattern":"Task not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/shared/src/core/orchestrator/task-manager.ts","lineNumber":151,"sourceCode":"    if (filter) {\n      if (filter.status) {\n        tasks = tasks.filter(t => t.status === filter.status);\n      }\n      if (filter.type) {\n        tasks = tasks.filter(t => t.type === filter.type);\n      }\n      if (filter.assignedAgent) {\n        tasks = tasks.filter(t => t.assignedAgent === filter.assignedAgent);\n      }\n    }\n\n    return tasks;\n  }\n\n  async assignTask(taskId: string, agentId: string): Promise<void> {\n    const task = this.tasks.get(taskId);\n    if (!task) {\n      throw new Error(`Task not found: ${taskId}`);\n    }\n\n    task.assignedAgent = agentId;\n    task.status = 'assigned';\n\n    this.eventBus.emit(SystemEventTypes.TASK_ASSIGNED, {\n      taskId,\n      agentId,\n    });\n  }\n\n  async startTask(taskId: string): Promise<void> {\n    const task = this.tasks.get(taskId);\n    if (!task) {\n      throw new Error(`Task not found: ${taskId}`);\n    }\n\n    task.status = 'running';","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/shared/src/core/orchestrator/task-manager.ts#L133-L169","documentation":"TaskManager.assignTask() resolves taskId through its in-memory tasks Map and throws when absent, before setting assignedAgent and status='assigned'. Only tasks created via createTask() (which mints a secure ID) exist in the map, so foreign or stale IDs cannot be assigned.","triggerScenarios":"Calling assignTask(taskId, agentId) with an ID not returned by createTask(); assigning tasks whose manager instance was recreated (e.g. after a restart); race where the task was cancelled and removed concurrently.","commonSituations":"Distributing task IDs via queues/IPC and consuming them in a process that never created those tasks; test setups reusing hard-coded IDs; multiple TaskManager instances sharding work.","solutions":["Verify with taskManager.getTask(taskId) before assigning","Create the task first via createTask() and use the returned task.id","Ensure producer and consumer share the same TaskManager instance or re-create tasks locally"],"exampleFix":"// before\nawait taskManager.assignTask(taskId, agentId);\n\n// after\nif (taskManager.getTask(taskId)) {\n  await taskManager.assignTask(taskId, agentId);\n}","handlingStrategy":"validation","validationCode":"const task = taskManager.getTask(taskId);\nif (!task) throw new Error(`unknown task ${taskId}`);\nawait taskManager.assignTask(taskId, agentId);","typeGuard":"const task = taskManager.getTask(taskId);\nif (task && task.status === 'pending') {\n  await taskManager.assignTask(task.id, agentId);\n}","tryCatchPattern":"try {\n  await taskManager.assignTask(taskId, agentId);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Task not found')) {\n    // drop or re-create the task; the ID is unknown to this manager\n  } else throw e;\n}","preventionTips":["Only use IDs returned by createTask() on the same TaskManager instance","Check getTask() before every state transition","Do not ship task IDs across process boundaries without re-creating tasks locally"],"tags":["task","not-found","assignment","orchestrator"],"backgroundTag":"entity-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}