{"record":{"id":"2915c3e06b5b8b23","repo":"slimtoolkit/slim","slug":"dockerimage-loadpackage-missing-layer-v-for-im","errorCode":null,"errorMessage":"dockerimage.LoadPackage: missing layer (%v) for image ID - %v","messagePattern":"dockerimage\\.LoadPackage: missing layer \\((.+?)\\) for image ID - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/docker/dockerimage/dockerimage.go","lineNumber":1154,"sourceCode":"\t\t//todo: save non-image layer metadata/data\n\t\tlog.Debugf(\"dockerimage.LoadPackage: no image layers in archive - %s (%+v)\",\n\t\t\tarchivePath, layerFileNames)\n\t}\n\n\tif len(nonLayerFileNames) > 0 {\n\t\tlog.Debugf(\"dockerimage.LoadPackage: non-image layers in archive - %s (%s)\",\n\t\t\tarchivePath, jsonutil.ToString(nonLayerFileNames))\n\t}\n\n\tlog.Debugf(\"dockerimage.LoadPackage: layerLocationSource=%v layerSequence='%#v' - archive='%s'\",\n\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 {","sourceCodeStart":1136,"sourceCodeEnd":1172,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerimage/dockerimage.go#L1136-L1172","documentation":"After loading all layer blobs, LoadPackage walks the manifest's layer sequence and requires each referenced layer ID to exist in the loaded layers map. A missing entry means a layer blob named by the manifest (layerLocationInfo.LayerID) was not found in the archive; the error reports the expected layer path and image ID.","triggerScenarios":"Calling LoadPackage where the manifest references a layer that is absent from the archive files: truncated download, layers pruned from a saved image, duplicate/deduplicated layer files removed, or layer digest mismatch between manifest and stored blob.","commonSituations":"Images shipped with shared/removed layers after aggressive registry GC; partial `docker save` of only some tags' layers; interrupted skopeo/crane copies; corporate proxies caching manifests but not all blobs.","solutions":["Re-create the archive so every manifest layer blob is present (full `docker save` / `crane pull`).","Check the logged layerPath/layerID against the archive contents and restore the missing blob at the expected path.","Run a completeness check (skopeo copy with --all, or tar -tf and compare layer digests to the manifest) before ingestion.","If the layer is legitimately absent, rebuild the image so all layers are regenerated."],"exampleFix":"// before: partial archive\n$ docker save myimage:1.0 | gzip > partial.tar.gz   # interrupted\n// after: complete export\n$ docker save -o full.tar myimage:1.0 && tar -tf full.tar | wc -l   # verify all layers","handlingStrategy":"validation","validationCode":"// compare manifest layer digests to archive contents before LoadPackage\nfunc allLayersPresent(files []string, layerDigests []string) error {\n\tfor _, d := range layerDigests {\n\t\tfound := false\n\t\tfor _, f := range files {\n\t\t\tif strings.Contains(f, d) { found = true; break }\n\t\t}\n\t\tif !found { return fmt.Errorf(\"layer %s missing from archive\", d) }\n\t}\n\treturn nil\n}","typeGuard":"func layerCount(p *dockerimage.Package, want int) bool { return p != nil && len(p.Layers) == want }","tryCatchPattern":"pkg, err := dockerimage.LoadPackage(...)\nif err != nil && strings.Contains(err.Error(), \"missing layer\") {\n\t// re-download/re-save the image; verify layer digests first next time\n}","preventionTips":["Use complete exports (docker save / crane pull) and avoid interrupted copies","Compare tar contents to manifest digests before ingestion","Avoid registry GC or blob pruning on images still being exported"],"tags":["oci","layers","docker","archive"],"backgroundTag":"missing-image-layer","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}