{"record":{"id":"28bb8f42cc9d7507","repo":"ruvnet/ruflo","slug":"dependency-task-depid-not-found","errorCode":null,"errorMessage":"Dependency task '${depId}' not found","messagePattern":"Dependency task '(.+?)' not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/swarm/src/application/commands/create-task.command.ts","lineNumber":50,"sourceCode":"  success: boolean;\n  taskId: string;\n  task: Task;\n  queuedAutomatically: boolean;\n}\n\n/**\n * Create Task Command Handler\n */\nexport class CreateTaskCommandHandler {\n  constructor(private readonly repository: ITaskRepository) {}\n\n  async execute(input: CreateTaskInput): Promise<CreateTaskResult> {\n    // Validate dependencies exist\n    if (input.dependencies && input.dependencies.length > 0) {\n      for (const depId of input.dependencies) {\n        const exists = await this.repository.exists(depId);\n        if (!exists) {\n          throw new Error(`Dependency task '${depId}' not found`);\n        }\n      }\n    }\n\n    // Create task\n    const task = Task.create({\n      title: input.title,\n      description: input.description,\n      type: input.type,\n      priority: input.priority,\n      dependencies: input.dependencies,\n      metadata: input.metadata,\n      input: input.input,\n      timeout: input.timeout,\n      maxRetries: input.maxRetries,\n    });\n\n    // Auto-queue if requested and no dependencies","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/swarm/src/application/commands/create-task.command.ts#L32-L68","documentation":"CreateTaskCommandHandler validates every id in input.dependencies with repository.exists(depId) before creating the task; any dangling reference aborts creation. This keeps the task graph a valid DAG — dependency tasks must exist in the repository before tasks that depend on them are created.","triggerScenarios":"input.dependencies contains the id of a task not yet created; a typo or copy-paste error in an id; the referenced task was deleted before this command ran; concurrent graph creation where the child command executes before the parent's save lands.","commonSituations":"A client builds a task graph offline and posts children before parents; ids carried over from another environment/repository instance; retrying a batch after some tasks were removed; test fixtures referencing hardcoded ids.","solutions":["Create dependency tasks first and pass their returned ids in dependencies.","Pre-validate each id with repository.exists(depId) before executing the create command.","Remove or correct stale ids in input.dependencies.","Serialize dependent creations (await the parent's create) instead of Promise.all over the whole graph."],"exampleFix":"// before\nawait createTask.execute({ title: 'deploy', dependencies: ['task-9'] }); // 'task-9' never created\n\n// after — create dependencies first, use the ids they return\nconst build = await createTask.execute({ title: 'build' });\nawait createTask.execute({ title: 'deploy', dependencies: [build.taskId] });","handlingStrategy":"validation","validationCode":"for (const depId of input.dependencies ?? []) {\n  if (!(await taskRepository.exists(depId))) {\n    throw new Error(`dependency ${depId} missing; create it first`);\n  }\n}\nawait createTaskHandler.execute(input);","typeGuard":null,"tryCatchPattern":"try {\n  await createTaskHandler.execute(input);\n} catch (e) {\n  if (e instanceof Error && /^Dependency task '.*' not found$/.test(e.message)) {\n    // create the missing parent tasks, then retry the command once\n  } else {\n    throw e;\n  }\n}","preventionTips":["Topologically sort task graphs and create tasks in dependency order.","Never hand-write dependency ids — propagate the ids returned by creation commands.","Serialize parent/child creation (await the parent) instead of Promise.all over the graph."],"tags":["task","dependencies","dag","validation"],"backgroundTag":"unresolved-dependency","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}