{"record":{"id":"bc2cbb94c957fb31","repo":"xpzouying/xiaohongshu-mcp","slug":"http-d-s","errorCode":null,"errorMessage":"HTTP %d: %s","messagePattern":"HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browser/browser_download.go","lineNumber":197,"sourceCode":"\t\t}\n\t\treturn nil\n\t})\n\tif found != \"\" {\n\t\tif err := os.Chmod(found, 0o755); err != nil {\n\t\t\tlogrus.Debugf(\"chmod %s: %v\", found, err)\n\t\t}\n\t}\n\treturn found\n}\n\nfunc downloadFile(url, dst string) error {\n\tresp, err := (&http.Client{Timeout: 10 * time.Minute}).Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"HTTP %d: %s\", resp.StatusCode, url)\n\t}\n\tf, err := os.Create(dst)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\t_, err = io.Copy(f, resp.Body)\n\treturn err\n}\n\nfunc extractArchive(archivePath, destDir string) error {\n\tswitch {\n\tcase strings.HasSuffix(archivePath, \".tar.xz\"):\n\t\treturn extractTarXz(archivePath, destDir)\n\tcase strings.HasSuffix(archivePath, \".zip\"):\n\t\treturn extractZip(archivePath, destDir)\n\tcase strings.HasSuffix(archivePath, \".dmg\"):\n\t\treturn extractDmg(archivePath, destDir)","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/browser/browser_download.go#L179-L215","documentation":"downloadFile performs the actual browser archive download with a 10-minute HTTP client and writes the body to dst. This error is thrown when the server responds with a status other than 200 OK, aborting the download before any file is created.","triggerScenarios":"EnsureBrowser -> downloadFile(url, dst) issues http.Get(url); the request succeeds but the CDN returns e.g. 404 (asset removed/renamed), 403 (blocked/rate limited), or 5xx (server error).","commonSituations":"Pinned browser version was deleted upstream; download URL constructed for the wrong OS/arch; corporate proxy or geo-block returns 403; CDN outage returns 502/503; GitHub-style rate limiting during CI with shared IPs.","solutions":["Fetch the URL with curl -I to see the exact status and any redirect target","Confirm the URL matches a currently published release for your OS/arch (404 usually means removed or wrong path)","For 403/429, check proxy/firewall rules and retry with backoff or from a different network","For 5xx, retry EnsureBrowser later — CDN outages are usually transient","Update the pinned browser version to one that still has downloadable assets"],"exampleFix":"// before\nresp, err := (&http.Client{Timeout: 10 * time.Minute}).Get(url)\nif err != nil { return err }\n// after — follow redirects explicitly and retry on transient statuses\nclient := &http.Client{Timeout: 10 * time.Minute, CheckRedirect: nil}\nfor attempt := 0; attempt < 3; attempt++ {\n\tresp, err := client.Get(url)\n\tif err == nil && resp.StatusCode == http.StatusOK { break }\n\ttime.Sleep(2 * time.Second)\n}","handlingStrategy":"retry","validationCode":"resp, err := http.Head(url)\nif err != nil || resp.StatusCode != http.StatusOK {\n\t// 下载地址不可用，先解决再调用 EnsureBrowser\n}","typeGuard":null,"tryCatchPattern":"if err := EnsureBrowser(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"HTTP \") {\n\t\t// 指数退避重试\n\t\ttime.Sleep(10 * time.Second)\n\t\terr = EnsureBrowser(ctx)\n\t}\n\tif err != nil { log.Fatal(err) }\n}","preventionTips":["Retry with exponential backoff on 5xx/429 only","Check URL correctness for your OS/arch before downloading","Bypass corporate proxies for download hosts if 403 persists","Pin to releases verified to still exist upstream"],"tags":["network","http","download"],"backgroundTag":"http-non-200-response","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}