{"record":{"id":"cdfd0758bece20d4","repo":"angular/angular-cli","slug":"unknown-task-dependency-id-id-id","errorCode":null,"errorMessage":"Unknown task dependency [ID: ${id.id}].","messagePattern":"Unknown task dependency \\[ID: (.+?)\\]\\.","errorType":"exception","errorClass":"UnknownTaskDependencyException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/src/engine/engine.ts","lineNumber":134,"sourceCode":"  private _calculatePriority(dependencies: Set<TaskInfo>): number {\n    if (dependencies.size === 0) {\n      return 0;\n    }\n\n    const prio = [...dependencies].reduce((prio, task) => prio + task.priority, 1);\n\n    return prio;\n  }\n\n  private _mapDependencies(dependencies?: Array<TaskId>): Set<TaskInfo> {\n    if (!dependencies) {\n      return new Set();\n    }\n\n    const tasks = dependencies.map((dep) => {\n      const task = this._taskIds.get(dep);\n      if (!task) {\n        throw new UnknownTaskDependencyException(dep);\n      }\n\n      return task;\n    });\n\n    return new Set(tasks);\n  }\n\n  schedule<T extends object>(taskConfiguration: TaskConfiguration<T>): TaskId {\n    const dependencies = this._mapDependencies(taskConfiguration.dependencies);\n    const priority = this._calculatePriority(dependencies);\n\n    const task = {\n      id: TaskScheduler._taskIdCounter++,\n      priority,\n      configuration: taskConfiguration,\n      context: this._context,\n    };","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/src/engine/engine.ts#L116-L152","documentation":"Schematics tasks are registered and referenced by opaque TaskId. _mapDependencies resolves a TaskConfiguration's dependencies array by looking each id up in the engine's `_taskIds` map; any id that was never registered (or already completed/cleared) throws UnknownTaskDependencyException. It indicates the scheduler was asked to wait on a task that does not exist in the current engine run.","triggerScenarios":"A schematic declares `options`/task dependencies referencing a task id obtained from a different SchematicEngine/context, or from a previous run, so `_taskIds.get(dep)` returns undefined during task scheduling via `dependencies()`.","commonSituations":"Caching task ids across engine instances or test setups; sharing task ids between separate `execute()` runs; a host schematic depending on a task id returned by a sub-schematic executed in a different engine.","solutions":["Only use TaskId values returned by `context.addTask(...)` within the same engine run that schedules the dependent task","Re-run the full pipeline so all referenced tasks are registered before their dependents are scheduled","If ids cross schematic boundaries, execute in the same engine/context instead of separate engines"],"exampleFix":"// before\nconst id = otherEngine.execute(...); // different engine\ncontext.addTask(new NodePackageInstallTask(), [id]);\n// after\nconst id = context.addTask(new RunSchematicTask('build', {}));\ncontext.addTask(new NodePackageInstallTask(), [id]); // same engine run","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import { UnknownTaskDependencyException } from '@angular-devkit/schematics';\ntry {\n  engine.execute(collectionName, options);\n} catch (err) {\n  if (err instanceof UnknownTaskDependencyException) {\n    console.error(`Task ${err.id} is not registered in this engine run; check task id usage.`);\n  } else throw err;\n}","preventionTips":["Never share TaskId values across different SchematicEngine instances or separate execute() runs","Obtain dependency ids only from context.addTask() within the same scheduling context","In tests, rebuild the whole task graph per run instead of caching ids"],"tags":["schematics","task-scheduling","lifecycle","angular-cli"],"backgroundTag":"unknown-task-dependency","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}