{"record":{"id":"ac61b83d289c6891","repo":"wagoodman/dive","slug":"unable-to-propagate-vm-view-tree-w","errorCode":null,"errorMessage":"unable to propagate vm view tree: %w","messagePattern":"unable to propagate vm view tree: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dive/cli/internal/ui/v1/viewmodel/filetree.go","lineNumber":445,"sourceCode":"\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to propagate vm model tree: %w\", err)\n\t}\n\n\t// make a new tree with only visible nodes\n\tvm.ViewTree = vm.ModelTree.Copy()\n\terr = vm.ViewTree.VisitDepthParentFirst(func(node *filetree.FileNode) error {\n\t\tif node.Data.ViewInfo.Hidden {\n\t\t\terr1 := vm.ViewTree.RemovePath(node.Path())\n\t\t\tif err1 != nil {\n\t\t\t\treturn err1\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}, nil)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to propagate vm view tree: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// Render flushes the state objects (file tree) to the pane.\nfunc (vm *FileTreeViewModel) Render() error {\n\ttreeString := vm.ViewTree.StringBetween(vm.bufferIndexLowerBound, vm.bufferIndexUpperBound(), vm.ShowAttributes)\n\tlines := strings.Split(treeString, \"\\n\")\n\n\t// update the contents\n\tvm.Buffer.Reset()\n\tfor idx, line := range lines {\n\t\tif idx == vm.bufferIndex {\n\t\t\t_, err := fmt.Fprintln(&vm.Buffer, format.Selected(vtclean.Clean(line, false)))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/ui/v1/viewmodel/filetree.go#L427-L463","documentation":"After Update copies ModelTree to ViewTree, it prunes hidden nodes with VisitDepthParentFirst + RemovePath and wraps any failure here. Because the traversal is parent-first, RemovePath can be called on a hidden directory while its children still exist — the classic way to hit this is a tree where a parent is hidden but children remain in the copy, making RemovePath fail. This is a real (if rare) error path, unlike the defensive visitor wraps.","triggerScenarios":"vm.ViewTree.RemovePath(node.Path()) returning an error during pruning: removing a node that still has children (parent-first order guarantees parents are visited before their hidden children are removed), or the path no longer resolving after earlier removals in the same pass.","commonSituations":"Aggressive hiding: hiding 'unmodified' or 'modified' diff types on large trees where entire directories qualify; combining a path filter with diff-type hiding so parent/child hidden flags diverge; deep directory trees where parent-first removal ordering matters.","solutions":["Toggle the hidden diff types back on (Ctrl+R style bindings) to restore a consistent tree and retry","Clear the path filter if one is active, then re-apply — it recomputes hidden flags coherently","If embedding/forking, prune child-first (VisitDepthChildFirst) so children are removed before parents","Report upstream if reproducible in stock dive with the filter/hide combination used"],"exampleFix":"// before: parent-first pruning can remove a dir before its hidden children\nerr := vm.ViewTree.VisitDepthParentFirst(visitor, nil)\n// after: child-first so children are pruned before their parents\nerr := vm.ViewTree.VisitDepthChildFirst(visitor, nil)","handlingStrategy":"fallback","validationCode":"// prune child-first so children are removed before parents\ncfg := filetree.VisitDepthChildFirst // ordering that avoids RemovePath-with-children errors","typeGuard":null,"tryCatchPattern":"err := vm.ViewTree.VisitDepthParentFirst(pruneVisitor, nil)\nif err != nil {\n    // fall back: flag hidden nodes instead of pruning so rendering still works\n    vm.ViewTree = vm.ModelTree.Copy()\n}","preventionTips":["Prune child-first (children before parents) to avoid RemovePath on nodes with children","Recompute all Hidden flags atomically before pruning","Avoid hiding diff types that orphan visible children under hidden parents"],"tags":["filetree","pruning","visibility","ordering"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}