{"record":{"id":"e11445f3f93dbffc","repo":"xtekky/gpt4free","slug":"download-failed-http-s","errorCode":null,"errorMessage":"download failed: HTTP %s","messagePattern":"download failed: HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"g4f-go/download.go","lineNumber":119,"sourceCode":"\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 {\n\t\tos.Remove(partName(binDir))\n\t\treturn fmt.Errorf(\"download interrupted: %w\", copyErr)\n\t}\n\tif err := os.Rename(partName(binDir), cachePath); err != nil {\n\t\tos.Remove(partName(binDir))\n\t\treturn err","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f-go/download.go#L101-L137","documentation":"downloadRuntime in g4f-go/download.go checks resp.StatusCode after a successful GET and errors with 'download failed: HTTP %s' for anything other than 200. This is a server-side response: the URL was reached but returned an error status (404 not found, 403 forbidden, 5xx, or a 3xx the client did not follow).","triggerScenarios":"spec.URL in runtime.json points to a moved/deleted artifact (404), the CDN requires auth or blocks your region/IP (403), the server is failing (5xx), or a redirect chain ends in an error because the client follows redirects to a signed URL that expired.","commonSituations":"Stale runtime.json referencing a released-then-deleted asset; expired pre-signed S3 URLs; CDN geo-blocking; GitHub asset links after a release was yanked.","solutions":["curl -I the exact spec.URL to confirm the status code","Update runtime.json (and the binary embedding it) to a release whose runtime asset still exists","For 403: check whether the host blocks unauthenticated or regional requests; use a mirror if provided","For 5xx: retry later once the hosting service recovers"],"exampleFix":"# before\n# runtime: download failed: HTTP 404 Not Found\n\n# after\ncurl -I \"https://host/runtime-linux-x64.tar.gz\"   # confirm 404\n# edit runtime.json -> point platforms.linux-x64.url at the current asset\n# rebuild/refresh the g4f-go binary so it embeds the fixed manifest","handlingStrategy":"try-catch","validationCode":"resp, err := http.Head(spec.URL)\nif err == nil && resp.StatusCode != http.StatusOK {\n    // stale/blocked asset: fix runtime.json before attempting the download\n}","typeGuard":null,"tryCatchPattern":"err := downloadRuntime(binDir, cachePath, spec)\nif err != nil && strings.Contains(err.Error(), \"download failed: HTTP\") {\n    // refresh the manifest URL / use a mirror, then retry once\n}","preventionTips":["Pin runtime URLs to immutable release assets, not mutable 'latest' links","Health-check the artifact URL (HEAD) during deploy scripts","Update runtime.json whenever release assets are re-published"],"tags":["go","download","http-status","runtime-manifest"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}