{"record":{"id":"b7b9b1eba48cbeca","repo":"wagoodman/dive","slug":"cannot-analyze-image-w","errorCode":null,"errorMessage":"cannot analyze image: %w","messagePattern":"cannot analyze image: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/dive/cli/internal/command/root.go","lineNumber":77,"sourceCode":"\t\t},\n\t}, opts)\n}\n\nfunc setUI(app clio.Application, opts options.Application) error {\n\ttype Stater interface {\n\t\tState() *clio.State\n\t}\n\n\tstate := app.(Stater).State()\n\n\tux := ui.NewV1UI(opts.V1Preferences(), os.Stdout, state.Config.Log.Quiet, state.Config.Log.Verbosity)\n\treturn state.UI.Replace(ux)\n}\n\nfunc run(ctx context.Context, opts options.Application, img *image.Image, content image.ContentReader) error {\n\tanalysis, err := adapter.NewAnalyzer().Analyze(ctx, img)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot analyze image: %w\", err)\n\t}\n\n\tif opts.Export.JsonPath != \"\" {\n\t\tif err := adapter.NewExporter(afero.NewOsFs()).ExportTo(ctx, analysis, opts.Export.JsonPath); err != nil {\n\t\t\treturn fmt.Errorf(\"cannot export analysis: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif opts.CI.Enabled {\n\t\teval := adapter.NewEvaluator(opts.CI.Rules.List).Evaluate(ctx, analysis)\n\n\t\tif !eval.Pass {\n\t\t\treturn errors.New(\"evaluation failed\")\n\t\t}\n\t\treturn nil\n\t}\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/command/root.go#L59-L95","documentation":"Returned from run() when the analyzer fails while processing the fetched image (adapter.NewAnalyzer().Analyze). At this point the image was fetched successfully; the failure is in reading layer metadata/tarballs and building the file tree — unsupported compression, corrupt layer blobs, or an engine API incompatibility.","triggerScenarios":"Analyze(ctx, img) on an image whose layer tarballs are corrupt or truncated, use compression schemes the analyzer cannot decode, or whose metadata layout does not match what the analyzer expects from this engine version.","commonSituations":"Interrupted docker pull leaving a partial layer in the cache; images pushed with experimental OCI media types by newer build tooling than dive supports; analyzing very large images that exhaust memory during tree construction; podman/docker major-version changes to storage layout.","solutions":["Read the wrapped error to see which layer/step failed","Re-pull the image from scratch (docker rmi + pull) to replace corrupted blobs","Upgrade dive to a release matching your engine version","Try the other engine as source or docker save/load the image to normalize its layout"],"exampleFix":"# before (possibly corrupt local layers)\ndive myapp:latest\n\n# after (force clean re-fetch)\ndocker rmi myapp:latest && docker pull myapp:latest && dive myapp:latest","handlingStrategy":"retry","validationCode":"// verify layer blobs are readable before full analysis\nfor _, l := range img.Layers {\n    if _, err := io.Copy(io.Discard, l.Reader()); err != nil {\n        return fmt.Errorf(\"layer unreadable, re-pull image: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"analysis, err := adapter.NewAnalyzer().Analyze(ctx, img)\nif err != nil {\n    if isCorruption(err) { // truncated blob: re-pull once, then retry\n        if rp := repull(ctx, img.Request); rp == nil {\n            analysis, err = adapter.NewAnalyzer().Analyze(ctx, img)\n        }\n    }\n    if err != nil { return fmt.Errorf(\"cannot analyze image: %w\", err) }\n}","preventionTips":["Re-pull images on cache corruption instead of retrying analysis","Keep dive and the container engine on compatible versions","Save analysis-exported JSON (--json) in CI to detect analyzer regressions early"],"tags":["analysis","layers","corruption","docker","podman"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}