{"record":{"id":"91868888f7d6da75","repo":"containerd/containerd","slug":"failed-to-resolve-layers-w","errorCode":null,"errorMessage":"failed to resolve layers: %w","messagePattern":"failed to resolve layers: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/images/archive/importer.go","lineNumber":172,"sourceCode":"\t\t}\n\t\tblobs[name] = desc\n\t}\n\n\tidx := ocispec.Index{\n\t\tVersioned: specs.Versioned{\n\t\t\tSchemaVersion: 2,\n\t\t},\n\t}\n\tfor _, mfst := range mfsts {\n\t\tconfig, ok := blobs[mfst.Config]\n\t\tif !ok {\n\t\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"image config %q not found\", mfst.Config)\n\t\t}\n\t\tconfig.MediaType = images.MediaTypeDockerSchema2Config\n\n\t\tlayers, err := resolveLayers(ctx, store, mfst.Layers, blobs, iopts.compress)\n\t\tif err != nil {\n\t\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to resolve layers: %w\", err)\n\t\t}\n\n\t\tmanifest := struct {\n\t\t\tSchemaVersion int                  `json:\"schemaVersion\"`\n\t\t\tMediaType     string               `json:\"mediaType\"`\n\t\t\tConfig        ocispec.Descriptor   `json:\"config\"`\n\t\t\tLayers        []ocispec.Descriptor `json:\"layers\"`\n\t\t}{\n\t\t\tSchemaVersion: 2,\n\t\t\tMediaType:     images.MediaTypeDockerSchema2Manifest,\n\t\t\tConfig:        config,\n\t\t\tLayers:        layers,\n\t\t}\n\n\t\tdesc, err := writeManifest(ctx, store, manifest, manifest.MediaType)\n\t\tif err != nil {\n\t\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"write docker manifest: %w\", err)\n\t\t}","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/core/images/archive/importer.go#L154-L190","documentation":"resolveLayers failed while mapping each layer filename in the manifest to an ingested blob descriptor and preparing content-store filters. The wrapped inner error carries the real cause (e.g. 'layer %q not found', media-type detection failures, or store walk errors). ImportIndex wraps it to attribute the failure to layer resolution for the current manifest.","triggerScenarios":"ImportIndex calls resolveLayers(ctx, store, mfst.Layers, blobs, compress) and it returns an error: a listed layer file is absent from blobs, the content-store Walk with LabelUncompressed filters fails, or detectLayerMediaType/ReaderAt/DecompressStream errors occur inside.","commonSituations":"Archives with truncated layer lists after manual editing; content store out of space or corrupted causing Walk/ReaderAt failures; layers stored as symlinks with missing targets; unusual compression formats the decompressor cannot sniff.","solutions":["Read the wrapped cause: if it says layer not found, fix the archive so every manifest.json Layers path exists in the tar","If the cause is a store error, check containerd content store health and disk space (`ctr content ls`, df)","Re-export the image with docker save or skopeo to get a clean archive","Verify layer compression (gzip/zstd/none) is standard and supported"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-validate that every manifest.json Layers path exists in the tar\nfor _, m := range mfsts {\n    for _, l := range m.Layers {\n        if !contains(tarFiles, l) { return fmt.Errorf(\"layer %s missing\", l) }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := client.Import(ctx, reader); err != nil {\n    if strings.Contains(err.Error(), \"failed to resolve layers\") {\n        log.Errorf(\"layer resolution failed: %v\", errors.Unwrap(err))\n        // branch on the wrapped cause (missing layer vs store error)\n    }\n    return err\n}","preventionTips":["Unwrap errors.Unwrap / %w chain to find the root cause before acting","Ensure the content store has free disk space and is healthy before large imports","Use standard tooling (docker save, skopeo) to produce archives","Set generous context timeouts for big images"],"tags":["image-import","layers","error-wrapping"],"backgroundTag":"layer-resolution-failed","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}