{"record":{"id":"74c035ee10eac8e4","repo":"angular/angular-cli","slug":"path-path-does-not-exist-74c035","errorCode":null,"errorMessage":"Path \"${path}\" does not exist.","messagePattern":"Path \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"FileDoesNotExistException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/src/tree/null.ts","lineNumber":78,"sourceCode":"    this[TreeSymbol] = () => this;\n  }\n\n  branch(): Tree {\n    return new NullTree();\n  }\n  merge(_other: Tree, _strategy?: MergeStrategy): void {}\n\n  readonly root: DirEntry = new NullTreeDirEntry(normalize('/'));\n\n  // Simple readonly file system operations.\n  exists(_path: string) {\n    return false;\n  }\n  read(_path: string) {\n    return null;\n  }\n  readText(path: string): string {\n    throw new FileDoesNotExistException(path);\n  }\n  readJson(path: string): JsonValue {\n    throw new FileDoesNotExistException(path);\n  }\n  get(_path: string) {\n    return null;\n  }\n  getDir(path: string): NullTreeDirEntry {\n    return new NullTreeDirEntry(normalize('/' + path));\n  }\n  visit(): void {}\n\n  // Change content of host files.\n  beginUpdate(path: string): never {\n    throw new FileDoesNotExistException(path);\n  }\n  commitUpdate(record: UpdateRecorder): never {\n    throw new FileDoesNotExistException(","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/src/tree/null.ts#L60-L96","documentation":"NullTree is a no-op tree used by schematics (e.g. for blank/empty rules); it intentionally has no files, so readText(path) always throws FileDoesNotExistException for every path. Reading any file from a NullTree can never succeed.","triggerScenarios":"Running a rule against a NullTree — commonly in unit tests using SchematicTestRunner with an empty/null collection, or code invoked with the tree from a 'blank' schematic — and calling tree.readText on any path.","commonSituations":"Testing a schematic without first writing template files into the test tree; a schematic that assumes a real project tree but is executed in a context that supplies NullTree; accidentally importing/using NullTree in production code paths.","solutions":["Populate the test tree with files before reading: use SchematicTestRunner and writeFile/app.caller, or run against a real sample app.","Guard with tree.exists(path) and skip or create the file when the tree is empty.","Verify the rule receives the intended Tree — don't construct NullTree outside tests; use HostTree/branch for in-memory manipulation."],"exampleFix":"// before\nconst text = tree.readText('/src/app/app.component.ts');\n// after\nif (!tree.exists('/src/app/app.component.ts')) {\n  return; // NullTree/empty test tree — nothing to do\n}\nconst text = tree.readText('/src/app/app.component.ts');","handlingStrategy":"validation","validationCode":"if (!tree.exists(path)) {\n  return; // NullTree or empty test tree\n}","typeGuard":null,"tryCatchPattern":"try {\n  const text = tree.readText(path);\n} catch (e) {\n  if ((e as any).constructor?.name === 'FileDoesNotExistException') {\n    return; // NullTree has no files\n  } else throw e;\n}","preventionTips":["In tests, populate the tree (writeFile / templates) before rules that read files","Guard reads with tree.exists() so empty/NullTree contexts are no-ops","Don't use NullTree in production paths; use HostTree or branch trees","Assert the schematic runs against a real project tree when file access is required"],"tags":["null-tree","file-not-found","testing","schematics"],"backgroundTag":"file-does-not-exist","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}