ruvnet/ruflo · error · Error

Dependency task '${depId}' not found

Error message

Dependency task '${depId}' not found

What it means

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.

Source

Thrown at v3/@claude-flow/swarm/src/application/commands/create-task.command.ts:50

  success: boolean;
  taskId: string;
  task: Task;
  queuedAutomatically: boolean;
}

/**
 * Create Task Command Handler
 */
export class CreateTaskCommandHandler {
  constructor(private readonly repository: ITaskRepository) {}

  async execute(input: CreateTaskInput): Promise<CreateTaskResult> {
    // Validate dependencies exist
    if (input.dependencies && input.dependencies.length > 0) {
      for (const depId of input.dependencies) {
        const exists = await this.repository.exists(depId);
        if (!exists) {
          throw new Error(`Dependency task '${depId}' not found`);
        }
      }
    }

    // Create task
    const task = Task.create({
      title: input.title,
      description: input.description,
      type: input.type,
      priority: input.priority,
      dependencies: input.dependencies,
      metadata: input.metadata,
      input: input.input,
      timeout: input.timeout,
      maxRetries: input.maxRetries,
    });

    // Auto-queue if requested and no dependencies

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Create dependency tasks first and pass their returned ids in dependencies.
  2. Pre-validate each id with repository.exists(depId) before executing the create command.
  3. Remove or correct stale ids in input.dependencies.
  4. Serialize dependent creations (await the parent's create) instead of Promise.all over the whole graph.

Example fix

// before
await createTask.execute({ title: 'deploy', dependencies: ['task-9'] }); // 'task-9' never created

// after — create dependencies first, use the ids they return
const build = await createTask.execute({ title: 'build' });
await createTask.execute({ title: 'deploy', dependencies: [build.taskId] });
Defensive patterns

Strategy: validation

Validate before calling

for (const depId of input.dependencies ?? []) {
  if (!(await taskRepository.exists(depId))) {
    throw new Error(`dependency ${depId} missing; create it first`);
  }
}
await createTaskHandler.execute(input);

Try / catch

try {
  await createTaskHandler.execute(input);
} catch (e) {
  if (e instanceof Error && /^Dependency task '.*' not found$/.test(e.message)) {
    // create the missing parent tasks, then retry the command once
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/28bb8f42cc9d7507. Report an issue: GitHub.