{"record":{"id":"0514d49853472e70","repo":"angular/angular-cli","slug":"collection-json-at-path-json-stringify-path-is","errorCode":null,"errorMessage":"Collection JSON at path ${JSON.stringify(path)} is invalid.","messagePattern":"Collection JSON at path (.+?) is invalid\\.","errorType":"exception","errorClass":"InvalidCollectionJsonException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts","lineNumber":165,"sourceCode":"  }\n\n  registerContextTransform(t: ContextTransform): void {\n    this._contextTransforms.push(t);\n  }\n\n  /**\n   *\n   * @param name\n   * @return {{path: string}}\n   */\n  createCollectionDescription(\n    name: string,\n    requester?: FileSystemCollectionDesc,\n  ): FileSystemCollectionDesc {\n    const path = this._resolveCollectionPath(name, requester?.path);\n    const jsonValue = readJsonFile(path);\n    if (!jsonValue || typeof jsonValue != 'object' || Array.isArray(jsonValue)) {\n      throw new InvalidCollectionJsonException(name, path);\n    }\n\n    // normalize extends property to an array\n    if (typeof jsonValue['extends'] === 'string') {\n      jsonValue['extends'] = [jsonValue['extends']];\n    }\n\n    const description = this._transformCollectionDescription(name, {\n      ...jsonValue,\n      path,\n    });\n    if (!description || !description.name) {\n      throw new InvalidCollectionJsonException(name, path);\n    }\n\n    // Validate aliases.\n    const allNames = Object.keys(description.schematics);\n    for (const schematicName of Object.keys(description.schematics)) {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts#L147-L183","documentation":"createCollectionDescription reads the resolved collection JSON file; if the parsed value is falsy, not an object, or an array, it throws InvalidCollectionJsonException with the file path. The file must be a JSON object describing the collection.","triggerScenarios":"A collection.json (or package.json used as collection) that is empty, contains 'null'/'[]', is truncated/invalid such that readJsonFile returns null, or resolves to a wrong file via _resolveCollectionPath.","commonSituations":"Hand-edited or corrupted collection.json files; build pipelines emitting empty JSON; misconfigured package.json missing schematics metadata so the wrong file is read; merge conflicts left as invalid JSON.","solutions":["Fix the collection.json at the printed path so it parses to a non-empty JSON object","Validate the JSON (e.g. node -e \"require('<path>')\") to catch syntax errors","Ensure the referenced package's package.json has a 'schematics' field pointing at the right collection file","Reinstall/repair the package if its files are truncated (rm -rf node_modules && npm i)"],"exampleFix":"// before (collection.json)\n[]\n// after (collection.json)\n{\n  \"$schema\": \"./node_modules/@angular-devkit/schematics/collection-schema.json\",\n  \"schematics\": {\n    \"my-schematic\": { \"factory\": \"./my-schematic/index\" }\n  }\n}","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'fs';\nfunction isValidCollectionJson(path: string): boolean {\n  try {\n    const v = JSON.parse(readFileSync(path, 'utf-8'));\n    return !!v && typeof v === 'object' && !Array.isArray(v);\n  } catch { return false; }\n}","typeGuard":"function isCollectionObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  await workflow.execute({ collection, schematic });\n} catch (e) {\n  if (/Collection JSON at path .* is invalid/.test(String(e))) {\n    const m = String(e).match(/at path (.+?) is invalid/);\n    console.error(`Fix the collection file at ${m?.[1]}`);\n  } else throw e;\n}","preventionTips":["Validate collection.json against the official collection-schema.json","Never leave merge-conflict markers or empty files in collection JSONs","Ensure package.json 'schematics' field points to an existing file","Parse-check custom collections in CI before publishing"],"tags":["schematics","json","schema-validation","configuration"],"backgroundTag":"invalid-collection-json","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}