{"record":{"id":"42bd15e09505f1ad","repo":"wagoodman/dive","slug":"unable-to-extract-from-image-q-v","errorCode":null,"errorMessage":"unable to extract from image %q: %+v","messagePattern":"unable to extract from image %q: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dive/image/podman/resolver.go","lineNumber":56,"sourceCode":"\t\treturn img, err\n\t}\n\n\treturn nil, fmt.Errorf(\"unable to resolve image %q: %+v\", id, err)\n}\n\nfunc (r *resolver) Extract(ctx context.Context, id string, l string, p string) error {\n\t// todo: add podman fetch attempt via varlink first...\n\n\terr, reader := streamPodmanCmd(\"image\", \"save\", id)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := docker.ExtractFromImage(io.NopCloser(reader), l, p); err == nil {\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"unable to extract from image %q: %+v\", id, err)\n}\n\nfunc (r *resolver) resolveFromDockerArchive(id string) (*image.Image, error) {\n\terr, reader := streamPodmanCmd(\"image\", \"save\", id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\timg, err := docker.NewImageArchive(io.NopCloser(reader))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn img.ToImage(id)\n}\n","sourceCodeStart":38,"sourceCodeEnd":71,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/dive/image/podman/resolver.go#L38-L71","documentation":"The podman resolver's Extract streams 'podman image save <id>' and hands the reader to docker.ExtractFromImage to unpack it to a destination path. If that extraction step errors (the early-return-on-nil-error structure means err here is the non-nil extraction error), it is wrapped as 'unable to extract from image'. Note the streamPodmanCmd failure path returns a different, unwrapped error.","triggerScenarios":"Calling resolver.Extract(ctx, id, l, p): 'podman image save' starts but the archive read/unpack fails mid-stream — invalid or truncated tar output, a layer entry the extractor cannot process, or unwritable/invalid destination path p / layer selector l. Also triggered when the image ID is wrong in a way that makes podman emit an error document instead of a tar.","commonSituations":"Extracting to a path without write permission or a nonexistent parent directory; disk full during extraction; image ID typo producing podman stderr piped into the tar reader; interrupted save stream (podman remote disconnections).","solutions":["Check the wrapped error detail: tar/manifest messages point at archive problems, permission messages at the destination","Verify the destination path exists and is writable: 'mkdir -p <dir> && touch <dir>/.write-test'","Confirm the image ID resolves: 'podman image save <id> -o /tmp/probe.tar' outside dive to see whether podman itself can save it","Re-pull or re-save the image if the probe tar is corrupt/truncated, then retry Extract"],"exampleFix":"# before\nerr := podmanResolver.Extract(ctx, \"myimg\", \"\", \"/tmp/out\")\n// unable to extract from image \"myimg\": ... (destination missing)\n\n# after\nmkdir -p /tmp/out && podman image save myimg -o /tmp/probe.tar  # sanity checks\nerr := podmanResolver.Extract(ctx, \"myimg\", \"\", \"/tmp/out\")","handlingStrategy":"validation","validationCode":"// Pre-flight the destination directory and the image before Extract.\nif err := os.MkdirAll(destPath, 0o755); err != nil { return err }\nif err := exec.Command(\"podman\", \"image\", \"save\", id, \"-o\", os.DevNull).Run(); err != nil {\n    return fmt.Errorf(\"podman cannot save %q: %w\", id, err)\n}\n// destination writable and image saveable; Extract is now likely to succeed","typeGuard":null,"tryCatchPattern":"if err := res.Extract(ctx, id, layer, path); err != nil {\n    if strings.Contains(err.Error(), \"unable to extract\") {\n        // inspect wrapped cause: permission -> fix dir mode; tar/manifest -> re-save image\n    }\n    return err\n}","preventionTips":["Create and permission-check destination directories before extraction","Keep disk headroom; extraction fails mid-stream when the filesystem fills","Smoke-test 'podman image save -o /dev/null <id>' to separate podman failures from extraction failures"],"tags":["podman","extraction","filesystem","dive"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}