{"record":{"id":"f64297f3e84d8b45","repo":"angular/angular-cli","slug":"need-workflow-to-support-executing-schematics-as-p","errorCode":null,"errorMessage":"Need Workflow to support executing schematics as post tasks.","messagePattern":"Need Workflow to support executing schematics as post tasks\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tasks/run-schematic/executor.ts","lineNumber":24,"sourceCode":" * found in the LICENSE file at https://angular.dev/license\n */\n\nimport { SchematicContext, TaskExecutor } from '../../src';\nimport { RunSchematicTaskOptions } from './options';\n\nexport default function (): TaskExecutor<RunSchematicTaskOptions<{}>> {\n  return (options: RunSchematicTaskOptions<{}> | undefined, context: SchematicContext) => {\n    if (!options?.name) {\n      throw new Error(\n        'RunSchematicTask requires an options object with a non-empty name property.',\n      );\n    }\n\n    const maybeWorkflow = context.engine.workflow;\n    const collection = options.collection || context.schematic.collection.description.name;\n\n    if (!maybeWorkflow) {\n      throw new Error('Need Workflow to support executing schematics as post tasks.');\n    }\n\n    return maybeWorkflow.execute({\n      collection: collection,\n      schematic: options.name,\n      options: options.options,\n      // Allow private when calling from the same collection.\n      allowPrivate: collection == context.schematic.collection.description.name,\n    });\n  };\n}\n","sourceCodeStart":6,"sourceCodeEnd":36,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tasks/run-schematic/executor.ts#L6-L36","documentation":"RunSchematicTask re-enters a workflow to execute the requested schematic as a post task. The engine's workflow reference (context.engine.workflow) is optional; base engines without workflow support leave it undefined and the executor throws instead of silently failing.","triggerScenarios":"Scheduling a RunSchematicTask while the engine was constructed without a Workflow-backed host (e.g. plain Engine host, custom test harnesses, older/basic workflow implementations).","commonSituations":"Custom schematic runners/CLIs built on the engine directly without creating a BaseWorkflow; test harnesses that stub the engine; running schematics programmatically with a minimal setup.","solutions":["Run schematics through a full Workflow implementation (e.g. BaseWorkflow from @angular-devkit/schematics) and attach it to the engine","Use the standard NodeWorkflow / testing workflow so context.engine.workflow is populated","Avoid RunSchematicTask in engines that lack workflow support; execute follow-up schematics directly instead","Update custom engine hosts to expose a workflow reference"],"exampleFix":"// before\nconst engine = new SchematicEngine(new MyBasicHost()); // no workflow\ncallSchematic(engine, { postTask: true }); // throws\n// after\nconst workflow = new NodeWorkflow(fsHost, { dryRun: false });\n// engine created by the workflow has context.engine.workflow available","handlingStrategy":"validation","validationCode":"if (!context.engine.workflow) {\n  throw new Error('Engine has no workflow; RunSchematicTask cannot be used.');\n}\ncontext.addTask(new RunSchematicTask({ name: 'post-setup' }));","typeGuard":"function supportsRunSchematic(context: SchematicContext): boolean {\n  return !!context.engine.workflow;\n}","tryCatchPattern":"try {\n  context.addTask(new RunSchematicTask(options));\n} catch (e) {\n  if (/Need Workflow/.test(String(e))) {\n    // execute the follow-up schematic directly via the workflow instead\n  } else throw e;\n}","preventionTips":["Run schematics through a full Workflow (NodeWorkflow / BaseWorkflow) when chaining RunSchematicTask","Avoid minimal engine hosts in production runners","Check context.engine.workflow availability in custom task scheduling code"],"tags":["schematics","workflow","tasks","architecture"],"backgroundTag":"workflow-not-supported","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}