{"record":{"id":"81133a705d06c2b5","repo":"angular/angular-cli","slug":"runschematictask-requires-an-options-object-with-a","errorCode":null,"errorMessage":"RunSchematicTask requires an options object with a non-empty name property.","messagePattern":"RunSchematicTask requires an options object with a non-empty name property\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tasks/run-schematic/executor.ts","lineNumber":15,"sourceCode":"/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * 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    });","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tasks/run-schematic/executor.ts#L1-L33","documentation":"The RunSchematicTask executor needs to know which schematic to run. If options is undefined or options.name is falsy, it throws, because the whole task is 'execute schematic <name>'.","triggerScenarios":"Scheduling a RunSchematicTask without options, with an empty name ('' or undefined), or constructing RunSchematicTaskOptions<T> where T doesn't include name and spreading options that shadow it.","commonSituations":"Custom schematics chaining post-tasks with dynamically computed options where the name variable is undefined; JSON option mismatches; copying task code and forgetting the name field.","solutions":["Always provide { name: '<schematicName>' } when scheduling the task","Verify the options object is spread after any defaults so name isn't overwritten with undefined","Add a guard/assertion on options.name before addTask","If the name is dynamic, resolve it before scheduling or throw your own descriptive error"],"exampleFix":"// before\ncontext.addTask(new RunSchematicTask({ collection: 'my-collection', options: {} })); // no name\n// after\ncontext.addTask(new RunSchematicTask({ collection: 'my-collection', name: 'setup', options: {} }));","handlingStrategy":"validation","validationCode":"function scheduleRunSchematic(context: SchematicContext, name: string, opts: object = {}) {\n  if (!name) throw new Error('RunSchematicTask: name is required');\n  context.addTask(new RunSchematicTask({ name, ...opts }));\n}","typeGuard":"function hasName(o: unknown): o is { name: string } {\n  return typeof (o as { name?: unknown })?.name === 'string' && (o as { name: string }).name !== '';\n}","tryCatchPattern":"try {\n  context.addTask(new RunSchematicTask(options));\n} catch (e) {\n  if (/non-empty name property/.test(String(e))) {\n    throw new Error(`RunSchematicTask misconfigured: ${JSON.stringify(options)}`);\n  } else throw e;\n}","preventionTips":["Always set name when constructing RunSchematicTaskOptions","Spread defaults before dynamic fields so name can't be clobbered by undefined","Add a small wrapper helper that enforces the name parameter"],"tags":["schematics","tasks","validation","angular"],"backgroundTag":"missing-required-task-option","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}