{"record":{"id":"ce6499fdaa4dfa43","repo":"angular/angular-cli","slug":"apply-not-implemented-on-host-trees","errorCode":null,"errorMessage":"Apply not implemented on host trees.","messagePattern":"Apply not implemented on host trees\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/src/tree/host-tree.ts","lineNumber":426,"sourceCode":"    } else {\n      throw new InvalidUpdateRecordException();\n    }\n  }\n\n  // Structural methods.\n  create(path: string, content: Buffer | string): void {\n    const c = typeof content == 'string' ? Buffer.from(content) : content;\n    this._record.create(this._normalizePath(path), c as {} as virtualFs.FileBuffer).subscribe();\n  }\n  delete(path: string): void {\n    this._recordSync.delete(this._normalizePath(path));\n  }\n  rename(from: string, to: string): void {\n    this._recordSync.rename(this._normalizePath(from), this._normalizePath(to));\n  }\n\n  apply(action: Action, strategy?: MergeStrategy): void {\n    throw new SchematicsException('Apply not implemented on host trees.');\n  }\n\n  private *generateActions(): Iterable<Action> {\n    for (const record of this._record.records()) {\n      switch (record.kind) {\n        case 'create':\n          yield {\n            id: this._id,\n            parent: 0,\n            kind: 'c',\n            path: record.path,\n            content: Buffer.from(record.content),\n          } as CreateFileAction;\n          break;\n        case 'overwrite':\n          yield {\n            id: this._id,\n            parent: 0,","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/src/tree/host-tree.ts#L408-L444","documentation":"HostTree.apply(action, strategy) is intentionally unimplemented: action-list application is only supported on branching/managed trees (e.g. BranchTree/DelegateTree or the workflow's task pipeline), not on a HostTree backed directly by a filesystem host. Any call throws SchematicsException with this message.","triggerScenarios":"Calling tree.apply(someAction) on a HostTree instance — e.g. via tree.newContent()/action flows that route to apply, or copying code that used Tree.apply on a different tree type.","commonSituations":"Custom schematics trying to replay recorded actions manually; code ported from older APIs or internal tooling that applied actions to the host tree; tests constructing HostTree directly and exercising action APIs.","solutions":["Remove the apply call — perform the change directly with create/overwrite/delete/rename on the tree instead.","Use a branching tree (tree.branch()) or the Schematic workflow's commit/task mechanisms if you need action-style batching.","Route actions through the engine's Tree (from the rule's context), which supports apply semantics, rather than a raw HostTree."],"exampleFix":"// before\ntree.apply(action, MergeStrategy.Default);\n// after\nif (action.kind === 'c') {\n  tree.create(action.path, action.content);\n} else if (action.kind === 'o') {\n  tree.overwrite(action.path, action.content);\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  (tree as any).apply(action, strategy);\n} catch (e) {\n  if ((e as Error).message.includes('Apply not implemented')) {\n    // translate the action to create/overwrite/delete/rename calls instead\n  } else throw e;\n}","preventionTips":["Never call apply on HostTree; apply changes via create/overwrite/delete/rename","Use branch trees or the schematic workflow for action batching needs","Get the Tree from the rule context rather than constructing HostTree for action flows","Wrap raw action application in a helper that maps action kinds to direct tree ops"],"tags":["not-implemented","actions","schematics"],"backgroundTag":"method-not-implemented","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}