{"record":{"id":"8e920f1606617e00","repo":"angular/angular-cli","slug":"schematic-input-does-not-validate-against-the-sche","errorCode":null,"errorMessage":"Schematic input does not validate against the Schema: ${JSON.stringify(options)}\nErrors:\n","messagePattern":"Schematic input does not validate against the Schema: (.+?)\nErrors:\n","errorType":"validation","errorClass":"InvalidInputOptions","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tools/schema-option-transform.ts","lineNumber":42,"sourceCode":"export function validateOptionsWithSchema(registry: schema.SchemaRegistry) {\n  return <T extends {} | null>(\n    schematic: FileSystemSchematicDescription,\n    options: T,\n    context?: FileSystemSchematicContext,\n  ): Observable<T> => {\n    // Prevent a schematic from changing the options object by making a copy of it.\n    options = structuredClone(options);\n\n    const withPrompts = context ? context.interactive : true;\n\n    if (schematic.schema && schematic.schemaJson) {\n      // Make a deep copy of options.\n      return from(registry.compile(schematic.schemaJson)).pipe(\n        mergeMap((validator) => validator(options, { withPrompts })),\n        first(),\n        map((result) => {\n          if (!result.success) {\n            throw new InvalidInputOptions(options, result.errors || []);\n          }\n\n          return options;\n        }),\n      );\n    }\n\n    return observableOf(options);\n  };\n}\n","sourceCodeStart":24,"sourceCodeEnd":53,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tools/schema-option-transform.ts#L24-L53","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the 'Errors:' list appended to the message — it names each failing path and constraint; fix those exact options first.","Supply all required options explicitly when running non-interactively (CI): add flags or pass a full options object to Schematic.create().","Check the schematic's schema.json (or --help) for correct option names and types; correct typos and value types (string vs boolean vs number).","Remove or rename options that are no longer allowed (unknown properties are rejected when the schema disallows additionalProperties)."],"exampleFix":"// before: invalid option type / missing required field in a script\nawait collection.createSchematic('component').call({ style: 3 });\n// after: match the schema (style must be a string; provide required options)\nawait collection\n  .createSchematic('component')\n  .call({ style: 'scss', skipTests: true, name: 'my-comp' });","handlingStrategy":"validation","validationCode":"const Ajv = require('ajv');\nconst ajv = new Ajv();\nconst validate = ajv.compile(schematic.schemaJson);\nif (!validate(options)) {\n  throw new Error('Invalid options: ' + ajv.errorsText(validate.errors));\n}","typeGuard":"function optionsMatchSchema(options, schema) {\n  const ajv = new (require('ajv'))();\n  return ajv.validate(schema, options) === true;\n}","tryCatchPattern":"try {\n  await schematic.call(options, host, { interactive: false });\n} catch (err) {\n  if (err instanceof InvalidInputOptions) {\n    console.error('Fix these option errors:', err.errors.map(e => `${e.instancePath} ${e.message}`).join('; '));\n  } else { throw err; }\n}","preventionTips":["Read the schematic's schema.json (or run `ng g name --help`) to learn exact option names, types, and required fields.","Always pass required options explicitly in CI/non-interactive runs, since prompts are skipped with withPrompts=false.","Parse JSON option strings before passing so values have correct types (booleans/numbers, not strings).","After upgrading a schematics package, diff its schema.json against the options your automation passes."],"tags":["angular","schematics","json-schema","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}