angular/angular-cli · error · InvalidInputOptions

Schematic input does not validate against the Schema: ${JSON

Error message

Schematic input does not validate against the Schema: ${JSON.stringify(options)}
Errors:

What it means

Thrown by validateOptionsWithSchema in packages/angular_devkit/schematics/tools/schema-option-transform.ts:42 when the options object passed to a schematic fails validation against the schematic's JSON schema (result.success === false). The error message embeds the offending options JSON and the list of validation errors from the schema registry, via the InvalidInputOptions exception.

Source

Thrown at packages/angular_devkit/schematics/tools/schema-option-transform.ts:42

export function validateOptionsWithSchema(registry: schema.SchemaRegistry) {
  return <T extends {} | null>(
    schematic: FileSystemSchematicDescription,
    options: T,
    context?: FileSystemSchematicContext,
  ): Observable<T> => {
    // Prevent a schematic from changing the options object by making a copy of it.
    options = structuredClone(options);

    const withPrompts = context ? context.interactive : true;

    if (schematic.schema && schematic.schemaJson) {
      // Make a deep copy of options.
      return from(registry.compile(schematic.schemaJson)).pipe(
        mergeMap((validator) => validator(options, { withPrompts })),
        first(),
        map((result) => {
          if (!result.success) {
            throw new InvalidInputOptions(options, result.errors || []);
          }

          return options;
        }),
      );
    }

    return observableOf(options);
  };
}

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Read the 'Errors:' list appended to the message — it names each failing path and constraint; fix those exact options first.
  2. Supply all required options explicitly when running non-interactively (CI): add flags or pass a full options object to Schematic.create().
  3. Check the schematic's schema.json (or --help) for correct option names and types; correct typos and value types (string vs boolean vs number).
  4. Remove or rename options that are no longer allowed (unknown properties are rejected when the schema disallows additionalProperties).

Example fix

// before: invalid option type / missing required field in a script
await collection.createSchematic('component').call({ style: 3 });
// after: match the schema (style must be a string; provide required options)
await collection
  .createSchematic('component')
  .call({ style: 'scss', skipTests: true, name: 'my-comp' });
Defensive patterns

Strategy: validation

Validate before calling

const Ajv = require('ajv');
const ajv = new Ajv();
const validate = ajv.compile(schematic.schemaJson);
if (!validate(options)) {
  throw new Error('Invalid options: ' + ajv.errorsText(validate.errors));
}

Type guard

function optionsMatchSchema(options, schema) {
  const ajv = new (require('ajv'))();
  return ajv.validate(schema, options) === true;
}

Try / catch

try {
  await schematic.call(options, host, { interactive: false });
} catch (err) {
  if (err instanceof InvalidInputOptions) {
    console.error('Fix these option errors:', err.errors.map(e => `${e.instancePath} ${e.message}`).join('; '));
  } else { throw err; }
}

Prevention

When it happens

Trigger: Invoking a schematic (Schematic.create(options) / `ng g name:action --flags`) with options that violate schemaJson: unknown keys when additionalProperties is false, missing required properties, wrong types (string where number expected), or unprompted required fields when withPrompts is false (e.g. non-interactive CI runs).

Common situations: Running schematics in CI (no TTY) without providing required options that would normally be prompted; passing flags with wrong names/types (e.g. --skip-tests=true vs boolean shorthand); passing JSON via a string with quoting issues so values arrive as wrong types; schematics package updated its schema and your script still passes old option names.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/8e920f1606617e00. Report an issue: GitHub.