{"record":{"id":"febed3bd1073e3e7","repo":"urfave/cli","slug":"download-file-from-2-s-into-3-s-response-1","errorCode":null,"errorMessage":"download file from %[2]s into %[3]s: response %[1]v","messagePattern":"download file from %\\[2\\]s into %\\[3\\]s: response %\\[1\\]v","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/build.go","lineNumber":212,"sourceCode":"\tfmt.Fprintf(os.Stderr, \"# ---> %s\\n\", cmd)\n\treturn cmd.Run()\n}\n\nfunc downloadFile(src, dest string, dirPerm, perm os.FileMode) error {\n\treq, err := http.NewRequest(http.MethodGet, src, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode >= 300 {\n\t\treturn fmt.Errorf(\"download file from %[2]s into %[3]s: response %[1]v\", resp.StatusCode, src, dest)\n\t}\n\n\tif err := os.MkdirAll(filepath.Dir(dest), dirPerm); err != nil {\n\t\treturn err\n\t}\n\n\tout, err := os.Create(dest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := io.Copy(out, resp.Body); err != nil {\n\t\treturn err\n\t}\n\n\tif err := out.Close(); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/scripts/build.go#L194-L230","documentation":"This build-script helper (scripts/build.go, downloadFile used by EnsureGfmrunActionFunc) downloads a file (e.g. the gfmrun binary) via HTTP GET and errors when the response status code is 300 or greater. The error names the source URL, the destination path, and the received status code.","triggerScenarios":"The URL passed as src returns a redirect chain that is not followed to a 2xx (e.g. bare 3xx without Location), a 404 because the requested version/tag of the asset no longer exists, a 403 from rate limiting (GitHub API limits), or a 5xx from the host.","commonSituations":"CI jobs pinning an outdated gfmrun version whose release asset was removed; GitHub rate-limit 403s on unauthenticated requests from shared CI IPs; network proxies returning 407/502; typos in the release URL.","solutions":["Check the reported status code: for 404, update the pinned version/URL in the build script to an existing release asset.","For 403 rate limits, add a GITHUB_TOKEN to the request or wait for the rate-limit window to reset.","For 5xx/3xx, retry later or verify the URL manually with curl -I; if redirects are being mishandled, use the final asset URL directly.","Run behind the corporate proxy: set HTTPS_PROXY so the request reaches the host correctly."],"exampleFix":"// before (pinned URL 404s)\nhttps://github.com/owner/gfmrun/releases/download/v1.2.9/gfmrun\n\n// after\nhttps://github.com/owner/gfmrun/releases/download/v1.4.0/gfmrun","handlingStrategy":"retry","validationCode":"// check the URL is reachable and returns 2xx before the build step\ncurl -fsSL -o /dev/null -w '%{http_code}' \"$GFMRUN_URL\" | grep -q '^2' \\\n  || { echo \"gfmrun asset unavailable: $GFMRUN_URL\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"for i in 1 2 3; do\n  if downloadFile \"$src\" \"$dest\" 0o755 0o644; then break; fi\n  echo \"download attempt $i failed; retrying in 5s\"; sleep 5\ndone","preventionTips":["Pin gfmrun versions that still have published release assets.","Authenticate GitHub downloads with a token to avoid 403 rate limits.","Verify release URLs with curl -I after bumping versions.","Respect proxy settings (HTTPS_PROXY) in CI environments."],"tags":["network","http","build","download","go"],"backgroundTag":"http-download-failed","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}