wagoodman/dive · error

unable to extract from image %q: %+v

Error message

unable to extract from image %q: %+v

What it means

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.

Source

Thrown at dive/image/podman/resolver.go:56

		return img, err
	}

	return nil, fmt.Errorf("unable to resolve image %q: %+v", id, err)
}

func (r *resolver) Extract(ctx context.Context, id string, l string, p string) error {
	// todo: add podman fetch attempt via varlink first...

	err, reader := streamPodmanCmd("image", "save", id)
	if err != nil {
		return err
	}

	if err := docker.ExtractFromImage(io.NopCloser(reader), l, p); err == nil {
		return nil
	}

	return fmt.Errorf("unable to extract from image %q: %+v", id, err)
}

func (r *resolver) resolveFromDockerArchive(id string) (*image.Image, error) {
	err, reader := streamPodmanCmd("image", "save", id)
	if err != nil {
		return nil, err
	}

	img, err := docker.NewImageArchive(io.NopCloser(reader))
	if err != nil {
		return nil, err
	}
	return img.ToImage(id)
}

View on GitHub (pinned to d6c691947f)

Solutions

  1. Check the wrapped error detail: tar/manifest messages point at archive problems, permission messages at the destination
  2. Verify the destination path exists and is writable: 'mkdir -p <dir> && touch <dir>/.write-test'
  3. Confirm the image ID resolves: 'podman image save <id> -o /tmp/probe.tar' outside dive to see whether podman itself can save it
  4. Re-pull or re-save the image if the probe tar is corrupt/truncated, then retry Extract

Example fix

# before
err := podmanResolver.Extract(ctx, "myimg", "", "/tmp/out")
// unable to extract from image "myimg": ... (destination missing)

# after
mkdir -p /tmp/out && podman image save myimg -o /tmp/probe.tar  # sanity checks
err := podmanResolver.Extract(ctx, "myimg", "", "/tmp/out")
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight the destination directory and the image before Extract.
if err := os.MkdirAll(destPath, 0o755); err != nil { return err }
if err := exec.Command("podman", "image", "save", id, "-o", os.DevNull).Run(); err != nil {
    return fmt.Errorf("podman cannot save %q: %w", id, err)
}
// destination writable and image saveable; Extract is now likely to succeed

Try / catch

if err := res.Extract(ctx, id, layer, path); err != nil {
    if strings.Contains(err.Error(), "unable to extract") {
        // inspect wrapped cause: permission -> fix dir mode; tar/manifest -> re-save image
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of wagoodman/dive@d6c691947f (2026-08-15). Data as JSON: /api/errors/42bd15e09505f1ad. Report an issue: GitHub.