{"record":{"id":"04bc361d91702a14","repo":"xtekky/gpt4free","slug":"download-failed-w","errorCode":null,"errorMessage":"download failed: %w","messagePattern":"download failed: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"g4f-go/download.go","lineNumber":113,"sourceCode":"\t\tfmt.Printf(\"runtime: cached download incomplete, re-downloading\\n\")\n\t}\n\n\tfmt.Printf(\"runtime: downloading CPython %s (%s)\\n\", \"3.14.7\", humanBytes(spec.Size))\n\tfmt.Printf(\"  %s\\n\", spec.URL)\n\tstart := time.Now()\n\n\tout, err := os.Create(partName(binDir))\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Network http.Client with no default timeout: progress is what keeps the\n\t// user informed, not a hard cutoff.\n\tclient := &http.Client{}\n\tresp, err := client.Get(spec.URL)\n\tif err != nil {\n\t\tout.Close()\n\t\tos.Remove(partName(binDir))\n\t\treturn fmt.Errorf(\"download failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\tout.Close()\n\t\tos.Remove(partName(binDir))\n\t\treturn fmt.Errorf(\"download failed: HTTP %s\", resp.Status)\n\t}\n\n\t// Prefer Content-Length; fall back to manifest size.\n\ttotal := resp.ContentLength\n\tif total <= 0 {\n\t\ttotal = spec.Size\n\t}\n\t_, copyErr := copyWithProgress(out, resp.Body, total, start)\n\tif cerr := out.Close(); copyErr == nil {\n\t\tcopyErr = cerr\n\t}\n\tif copyErr != nil {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f-go/download.go#L95-L131","documentation":"downloadRuntime in g4f-go/download.go wraps the raw http.Client.Get error as 'download failed: %w'. The client is created with no timeout (progress is the feedback mechanism), so this fires on connection-level failures: DNS resolution, refused connections, TLS handshake errors — anything before a response is received.","triggerScenarios":"client.Get(spec.URL) failing: no internet, DNS for the runtime host broken, TLS certificate verification failure, firewall/proxy blocking the runtime CDN, or the URL scheme being invalid.","commonSituations":"Offline machines; corporate TLS-intercepting proxies without the CA in the system pool; IPv6-broken networks causing dial timeouts; mistyped URL in a locally modified runtime.json.","solutions":["Check connectivity to the runtime URL (curl -I <spec.URL>) and fix DNS/proxy/firewall issues","If behind a TLS-intercepting proxy, install its CA into the system trust store or set SSL_CERT_FILE","Inspect the wrapped error (%w) with errors.Unwrap / %v to see whether it is dial, DNS, or TLS","Retry — transient network failures are common for large runtime downloads"],"exampleFix":"# before\ng4f  # runtime: download failed: dial tcp: lookup cdn.example: no such host\n\n# after\n# fix DNS or proxy, or point to a reachable mirror in runtime.json\ncurl -I https://your-runtime-host/runtime.tar.gz  # verify reachability","handlingStrategy":"retry","validationCode":"if _, err := net.LookupHost(urlHost(spec.URL)); err != nil {\n    // DNS broken: fail fast with a clear message before downloading\n}","typeGuard":null,"tryCatchPattern":"err := downloadRuntime(binDir, cachePath, spec)\nif err != nil {\n    if var ne net.Error; errors.As(err, &ne) || strings.Contains(err.Error(), \"download failed\") {\n        // exponential backoff retry, then surface the unwrapped cause\n    }\n    return err\n}","preventionTips":["Verify DNS/TLS/proxy reachability to the runtime host before deploying","Add SSL_CERT_FILE/system CA setup behind TLS-intercepting proxies","Wrap downloads in a bounded retry loop with backoff"],"tags":["go","network","download","tls","proxy"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}