{"record":{"id":"3412762b5c3500dd","repo":"dagger/dagger","slug":"cannot-determine-diff-of-more-than-one-upper-direc","errorCode":null,"errorMessage":"cannot determine diff of more than one upper directories","messagePattern":"cannot determine diff of more than one upper directories","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/snapshots/fsdiff/overlay_linux.go","lineNumber":57,"sourceCode":"\t\t\tlowerlayers, err = GetOverlayLayers(lowerM)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t} else {\n\t\t\treturn \"\", errors.Errorf(\"cannot get layer information from mount option (type = %q)\", lowerM.Type)\n\t\t}\n\n\t\tupperM := upper[0]\n\t\tif !IsOverlayMountType(upperM) {\n\t\t\treturn \"\", errors.Errorf(\"upper snapshot isn't overlay mounted (type = %q)\", upperM.Type)\n\t\t}\n\t\tupperlayers, err := GetOverlayLayers(upperM)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif len(upperlayers) != len(lowerlayers)+1 {\n\t\t\treturn \"\", errors.Errorf(\"cannot determine diff of more than one upper directories\")\n\t\t}\n\t\tfor i := 0; i < len(lowerlayers); i++ {\n\t\t\tif upperlayers[i] != lowerlayers[i] {\n\t\t\t\treturn \"\", errors.Errorf(\"layer %d must be common between upper and lower snapshots\", i)\n\t\t\t}\n\t\t}\n\t\tupperdir = upperlayers[len(upperlayers)-1]\n\t} else {\n\t\treturn \"\", errors.Errorf(\"multiple mount configurations are not supported\")\n\t}\n\tif upperdir == \"\" {\n\t\treturn \"\", errors.Errorf(\"cannot determine upperdir from mount option\")\n\t}\n\treturn upperdir, nil\n}\n\nfunc GetOverlayLayers(m mount.Mount) ([]string, error) {\n\tvar u string","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/snapshots/fsdiff/overlay_linux.go#L39-L75","documentation":"GetUpperdir derives the overlayfs upperdir of a snapshot by comparing the layer lists parsed from the lower and upper overlay mounts. The diff logic only supports the case where the upper mount's layer stack is exactly the lower mount's stack plus exactly one new top layer (the upperdir). When the upper mount contains more than one additional layer relative to the lower mount, the code cannot unambiguously attribute changes to a single upperdir and throws this error.","triggerScenarios":"Calling differFor/GetUpperdir with lower=[1 overlay mount] and upper=[1 overlay mount] where the upper mount's lowerdir stack differs in length from the lower mount's stack by more than one entry — e.g. the lower snapshot was committed and re-based so its overlay gained 2+ new layers, or the lower mount is a plain bind mount (len(lowerlayers)==1) while the upper overlay has 3+ layers.","commonSituations":"Diffing across non-adjacent snapshot generations after multiple commits; a snapshotter that squashed or re-created layers between snapshots; comparing a bind-mounted base snapshot against a multi-layer overlay snapshot; containerd overlay snapshotter garbage-collecting or remounting layers between the two mount fetches.","solutions":["Ensure you diff between adjacent snapshots only: the upper snapshot must be exactly one layer on top of the lower snapshot","Re-fetch both mounts at the same time so they refer to a consistent layer chain (avoid GC/remount races between calls)","If you need multi-layer diffs, compute the diff incrementally layer by layer instead of a single GetUpperdir call","Verify the lower mount is an overlay mount (not bind) so lowerlayers is the full stack rather than a single entry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"upperLayers, err := fsdiff.GetOverlayLayers(upperM)\nif err != nil { return err }\nvar lowerLayers []string\nif lowerM.Type == \"bind\" {\n    lowerLayers = []string{lowerM.Source}\n} else {\n    lowerLayers, err = fsdiff.GetOverlayLayers(lowerM)\n    if err != nil { return err }\n}\nif len(upperLayers) != len(lowerLayers)+1 {\n    return fmt.Errorf(\"snapshots are not adjacent: upper has %d layers, lower has %d\", len(upperLayers), len(lowerLayers))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only diff parent/child snapshot pairs (one layer apart)","Fetch both mounts together to avoid GC/remount races","Log parsed layer lists before diffing to catch count drift early"],"tags":["overlayfs","linux","diff","snapshot"],"backgroundTag":"overlay-layer-count-mismatch","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}