{"record":{"id":"0ea8386a481b8a78","repo":"lima-vm/lima","slug":"failed-to-download-q-w","errorCode":null,"errorMessage":"failed to download %#q: %w","messagePattern":"failed to download %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fileutils/download.go","lineNumber":40,"sourceCode":"func DownloadFile(ctx context.Context, dest string, f limatype.File, decompress bool, description string, expectedArch limatype.Arch, supportedImageFormats []string) (string, error) {\n\tif f.Arch != expectedArch {\n\t\treturn \"\", fmt.Errorf(\"%w: %#q: unsupported arch: %#q\", ErrSkipped, f.Location, f.Arch)\n\t}\n\tfields := logrus.Fields{\"location\": f.Location, \"arch\": f.Arch, \"digest\": f.Digest}\n\tlogrus.WithFields(fields).Infof(\"Attempting to download %s\", description)\n\topts := []downloader.Opt{\n\t\tdownloader.WithCache(),\n\t\tdownloader.WithDecompress(decompress),\n\t\tdownloader.WithDescription(fmt.Sprintf(\"%s (%s)\", description, path.Base(f.Location))),\n\t\tdownloader.WithExpectedDigest(f.Digest),\n\t}\n\tif len(supportedImageFormats) > 0 {\n\t\topts = append(opts, downloader.WithImageFormats(supportedImageFormats))\n\t}\n\n\tres, err := downloader.Download(ctx, dest, f.Location, opts...)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to download %#q: %w\", f.Location, err)\n\t}\n\tlogrus.Debugf(\"res.ValidatedDigest=%v\", res.ValidatedDigest)\n\tswitch res.Status {\n\tcase downloader.StatusDownloaded:\n\t\tlogrus.Infof(\"Downloaded %s from %#q\", description, f.Location)\n\tcase downloader.StatusUsedCache:\n\t\tlogrus.Infof(\"Using cache %#q\", res.CachePath)\n\tdefault:\n\t\tlogrus.Warnf(\"Unexpected result from downloader.Download(): %+v\", res)\n\t}\n\treturn res.CachePath, nil\n}\n\n// CachedFile checks if a file is in the cache, validating the digest if it is available. Returns path in cache.\nfunc CachedFile(f limatype.File) (string, error) {\n\tres, err := downloader.Cached(f.Location,\n\t\tdownloader.WithCache(),\n\t\tdownloader.WithExpectedDigest(f.Digest))","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/fileutils/download.go#L22-L58","documentation":"DownloadFile wraps any error returned by downloader.Download into \"failed to download %#q: %w\". This means the actual download (network fetch into cache) failed for the given location, with the underlying cause (HTTP error, DNS failure, digest mismatch, context cancellation) preserved.","triggerScenarios":"downloader.Download returns an error during DownloadFile — network unreachable, HTTP 404/403 on the file URL, TLS failures, disk full when writing cache, or canceled context.","commonSituations":"Offline or firewalled environments; stale template URLs pointing at removed releases; corporate proxy blocking the download; wrong digest in the file entry causing validation failure.","solutions":["Inspect the wrapped cause for the concrete HTTP/network error","Verify the URL in the template is reachable (curl -I the location)","Fix network/proxy settings (HTTPS_PROXY etc.) and retry","Update the template to a valid current release URL; check the expected digest matches the artifact"],"exampleFix":"// before\n# stale URL\nlocation: \"https://example.com/old-release/image.iso\"\n// after\nlocation: \"https://example.com/current-release/image.iso\"","handlingStrategy":"retry","validationCode":"// check reachability before invoking the flow\nresp, err := http.Head(f.Location)\nif err != nil || resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"location %s unreachable\", f.Location)\n}","typeGuard":null,"tryCatchPattern":"path, err := fileutils.DownloadFile(ctx, dest, f, decompress, desc, arch, formats)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"failed to download\") {\n        // retry with backoff; the wrapped cause says why it failed\n        return retryDownload(ctx, f)\n    }\n    return err\n}","preventionTips":["Verify template URLs are current and reachable","Configure proxies/certificates for corporate networks","Pin digests and confirm they match artifacts","Retry transient network errors with backoff"],"tags":["download","network","http"],"backgroundTag":"download-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}