{"record":{"id":"ff40bcd1f8c3f576","repo":"angular/angular-cli","slug":"the-not-keyword-is-not-supported-in-json-schema","errorCode":null,"errorMessage":"The \"not\" keyword is not supported in JSON Schema.","messagePattern":"The \"not\" keyword is not supported in JSON Schema\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/command-builder/utilities/json-schema.ts","lineNumber":329,"sourceCode":"  const options: Option[] = [];\n\n  function visitor(\n    current: json.JsonObject | json.JsonArray,\n    pointer: json.schema.JsonPointer,\n    parentSchema?: json.JsonObject | json.JsonArray,\n  ) {\n    if (\n      !parentSchema ||\n      json.isJsonArray(current) ||\n      pointer.split(/\\/(?:properties|items|definitions)\\//g).length > 2\n    ) {\n      // Ignore root, arrays, and subitems.\n      return;\n    }\n\n    if (pointer.includes('/not/')) {\n      // We don't support anyOf/not.\n      throw new Error('The \"not\" keyword is not supported in JSON Schema.');\n    }\n\n    const ptr = json.schema.parseJsonPointer(pointer);\n    if (ptr[ptr.length - 2] !== 'properties') {\n      // Skip any non-property items.\n      return;\n    }\n    const name = ptr.at(-1) as string;\n\n    const types = getSupportedTypes(current);\n\n    if (types.length === 0) {\n      // This means it's not usable on the command line. e.g. an Object.\n      return;\n    }\n\n    const [type] = types;\n    const $default = current.$default;","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/command-builder/utilities/json-schema.ts#L311-L347","documentation":"The CLI converts a command's JSON Schema into yargs options. JSON Schema's 'not' keyword (and by extension schemas using it) cannot be represented as positive yargs constraints, so the schema visitor throws when it encounters a '/not/' JSON pointer.","triggerScenarios":"A schematic or command defines its schema.json with a 'not' keyword on a property; invoking 'ng g' or a command whose builder schema uses 'not'/'anyOf'+'not' composition.","commonSituations":"Custom/community schematics authored with advanced JSON Schema keywords; upgrading a schematic to a newer CLI that no longer tolerates 'not'; hand-written strict validation in a builder schema.","solutions":["Rewrite the schematic's schema.json to avoid 'not' (use enum/const/pattern with inverse semantics instead)","Replace {\"not\": {...}} with explicit allowed values, e.g. enum listing valid inputs","If it's a third-party schematic, report/upgrade to a version compatible with the CLI's schema parser","Pin the CLI version that accepted the schema while migrating"],"exampleFix":"// before (schema.json)\n{\"type\":\"string\",\"not\":{\"enum\":[\"forbidden\"]}}\n// after\n{\"type\":\"string\",\"enum\":[\"allowed-a\",\"allowed-b\"]}","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'fs';\nconst schema = JSON.parse(readFileSync(schemaPath, 'utf8'));\nfunction usesNotKeyword(schema: unknown): boolean {\n  return JSON.stringify(schema).includes('\"not\"');\n}\nif (usesNotKeyword(schema)) {\n  console.warn('Schema uses unsupported \"not\" keyword for CLI option parsing');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngGenerate(schematic, options);\n} catch (e) {\n  if ((e as Error).message.includes('\"not\" keyword')) {\n    console.error('Schematic schema uses JSON Schema \"not\"; upgrade the schematic package.');\n  } else throw e;\n}","preventionTips":["Author schematic schemas with only enum/const/pattern/allOf/anyOf (no 'not')","Test custom schematics against the CLI version you ship with","Prefer explicit allowed-value lists over negation in builder schemas"],"tags":["angular-cli","json-schema","schematics","yargs"],"backgroundTag":"unsupported-json-schema-keyword","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}