{"record":{"id":"b511eeea63094f03","repo":"slimtoolkit/slim","slug":"dockerimage-loadpackage-layer-path-mismatch-v","errorCode":null,"errorMessage":"dockerimage.LoadPackage: layer path mismatch - %v / %v","messagePattern":"dockerimage\\.LoadPackage: layer path mismatch - (.+?) / (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/docker/dockerimage/dockerimage.go","lineNumber":1165,"sourceCode":"\t\tlayerLocationSource, layerSequence, archivePath)\n\n\tfor idx, layerLocationInfo := range layerSequence {\n\t\tlayer, ok := layers[layerLocationInfo.LayerID]\n\t\tif !ok {\n\t\t\tlog.Errorf(\"dockerimage.LoadPackage: error missing layer (idx=%d layerPath=%s layerID=%s) archive=%s\",\n\t\t\t\tidx, layerLocationInfo.Path, layerLocationInfo.LayerID, archivePath)\n\t\t\treturn nil, fmt.Errorf(\"dockerimage.LoadPackage: missing layer (%v) for image ID - %v\", layerLocationInfo.Path, imageID)\n\t\t}\n\n\t\tlayer.Index = idx\n\t\t//adding layers based on their manifest order\n\t\tpkg.Layers = append(pkg.Layers, layer)\n\t\tif len(pkg.Layers)-1 != layer.Index {\n\t\t\treturn nil, fmt.Errorf(\"dockerimage.LoadPackage: layer index mismatch - %v / %v\", len(pkg.Layers)-1, layer.Index)\n\t\t}\n\n\t\tif layerLocationInfo.Path != layer.Path {\n\t\t\treturn nil, fmt.Errorf(\"dockerimage.LoadPackage: layer path mismatch - %v / %v\", layerLocationInfo.Path, layer.Path)\n\t\t}\n\n\t\tif idx == 0 {\n\t\t\tfor oidx, object := range layer.Objects {\n\t\t\t\tobject.LayerIndex = idx\n\n\t\t\t\tif utf8Detector != nil {\n\t\t\t\t\tswitch object.ContentType {\n\t\t\t\t\tcase ContentTypeUTF8:\n\t\t\t\t\t\tlayer.Stats.UTF8Count++\n\t\t\t\t\t\tlayer.Stats.UTF8Size += uint64(object.Size)\n\t\t\t\t\t\tpkg.Stats.UTF8Count++\n\t\t\t\t\t\tpkg.Stats.UTF8Size += uint64(object.Size)\n\t\t\t\t\tcase ContentTypeBinary:\n\t\t\t\t\t\tlayer.Stats.BinaryCount++\n\t\t\t\t\t\tlayer.Stats.BinarySize += uint64(object.Size)\n\t\t\t\t\t\tpkg.Stats.BinaryCount++\n\t\t\t\t\t\tpkg.Stats.BinarySize += uint64(object.Size)","sourceCodeStart":1147,"sourceCodeEnd":1183,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerimage/dockerimage.go#L1147-L1183","documentation":"LoadPackage cross-checks each layer's declared filesystem path (layerLocationInfo.Path from the manifest) against the path recorded on the loaded layer object (layer.Path). A mismatch means the archive's location metadata and the loaded layer disagree — the resolved blob does not correspond to the manifest entry, so proceeding could attribute the wrong filesystem contents to the image.","triggerScenarios":"Calling LoadPackage where a manifest layer location resolves to a layer object loaded from a different path — e.g. blobs moved/renamed after indexing, symlinks pointing elsewhere, digest-keyed directories remapped, or a loader cache returning a layer keyed by ID but recorded with a different path.","commonSituations":"Post-processing tools that reorganize OCI blob directories; archives extracted with symlinks resolved differently; merging archives where the same layer digest exists at multiple paths and the wrong one is picked.","solutions":["Re-export the archive so manifest layer paths match the stored blob locations one-to-one.","Check whether any pre-processing moved/renamed blobs and undo or update the manifest location entries to match.","Clear any layer cache that could return stale layer objects with outdated Path values, then retry the load.","Compare the two paths in the error message to identify which side is stale and correct that artifact."],"exampleFix":"// before: blob renamed after manifest written\n$ mv blobs/sha256/abc... blobs/sha256/xyz...\n// after: keep digests as-is\n$ crane pull app:1.0 app.tar   # manifest paths match blob digests","handlingStrategy":"validation","validationCode":"// ensure every manifest layer path exists at its expected location before load\nfunc layerPathsExist(locs []struct{ Path string }) error {\n\tfor _, l := range locs {\n\t\tif _, err := os.Stat(l.Path); err != nil {\n\t\t\treturn fmt.Errorf(\"layer path %s missing: %w\", l.Path, err)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func pathsMatch(locPath, layerPath string) bool { return filepath.Clean(locPath) == filepath.Clean(layerPath) }","tryCatchPattern":"pkg, err := dockerimage.LoadPackage(...)\nif err != nil && strings.Contains(err.Error(), \"layer path mismatch\") {\n\t// fix blob locations or re-export; compare both paths in the error\n}","preventionTips":["Never rename/move blobs inside an OCI layout after the manifest is written","Extract archives without resolving symlinks differently from the layout","Use digest-keyed paths (blobs/sha256/<digest>) so paths and digests agree"],"tags":["oci","layers","path-mismatch","docker"],"backgroundTag":"layer-path-mismatch","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}