{"record":{"id":"ae3417072bf0982c","repo":"wagoodman/dive","slug":"could-not-stack-tree-range-w","errorCode":null,"errorMessage":"could not stack tree range: %w","messagePattern":"could not stack tree range: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"dive/filetree/file_tree.go","lineNumber":386,"sourceCode":"func (tree *FileTree) markRemoved(path string) error {\n\tnode, err := tree.GetNode(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn node.AssignDiffType(Removed)\n}\n\n// StackTreeRange combines an array of trees into a single tree\nfunc StackTreeRange(trees []*FileTree, start, stop int) (*FileTree, []PathError, error) {\n\terrors := make([]PathError, 0)\n\ttree := trees[0].Copy()\n\tfor idx := start; idx <= stop; idx++ {\n\t\tfailedPaths, err := tree.Stack(trees[idx])\n\t\tif len(failedPaths) > 0 {\n\t\t\terrors = append(errors, failedPaths...)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"could not stack tree range: %w\", err)\n\t\t}\n\t}\n\treturn tree, errors, nil\n}\n","sourceCodeStart":368,"sourceCodeEnd":391,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/dive/filetree/file_tree.go#L368-L391","documentation":"Returned by StackTreeRange (dive/filetree/file_tree.go:386), which folds a range of layer trees into one. It wraps the error returned by FileTree.Stack for any layer in [start, stop]. Stack itself delegates to VisitDepthChildFirst whose graft callback always returns nil, so in stock code the wrapped error is essentially unreachable; per-path stacking failures are instead accumulated as PathError values in the second return value, which this error does not describe.","triggerScenarios":"A tree visitor implementation that returns an error while grafting a layer (only possible in forks or custom visitor wrappers), since the bundled graft closure cannot fail.","commonSituations":"Not observed with upstream dive. If it appears, suspect a modified fork, a corrupted in-memory tree (nil children from earlier misuse), or a future regression in Stack.","solutions":["Inspect the wrapped error chain with errors.Unwrap/As - the %w keeps the original cause","Confirm you are on stock dive and that the input trees were built by the library, not hand-constructed with nil payloads","Report upstream with the wrapped cause if reproducible on unmodified code"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// guard the inputs StackTreeRange assumes: non-empty slice, valid range\ntree, pathErrs, err := filetree.StackTreeRange(trees, start, stop)\nif err != nil {\n    if cause := errors.Unwrap(err); cause != nil {\n        log.Printf(\"stack failure root cause: %v\", cause)\n    }\n}","typeGuard":null,"tryCatchPattern":"tree, failed, err := filetree.StackTreeRange(trees, start, stop)\nif err != nil {\n    return fmt.Errorf(\"stacking layers %d-%d: %w\", start, stop, err)\n}\n// per-path failures are in `failed`, not `err` - log them separately:\nfor _, pe := range failed {\n    log.Printf(\"path issue: %+v\", pe)\n}","preventionTips":["Remember per-path failures arrive via the PathError slice, not this error","Keep start<=stop<len(trees); validate the range before calling","Unwrap the %w chain to find the real cause if it ever fires"],"tags":["filetree","layering","defensive-code","unreachable"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}