{"record":{"id":"2f5bf16dc46ef677","repo":"can1357/oh-my-pi","slug":"failed-to-download-filename-repo-http-r","errorCode":null,"errorMessage":"Failed to download ${filename} (${repo}): HTTP ${response.status}","messagePattern":"Failed to download (.+?) \\((.+?)\\): HTTP (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/stt/asr-worker.ts","lineNumber":271,"sourceCode":"}\n\n/**\n * Stream a single sherpa-onnx model file from the Hub into the cache, writing to\n * a `.part` sidecar and renaming on completion so an interrupted fetch never\n * reads as cached. Emits coalesced per-file progress for the aggregating client.\n */\nasync function downloadSherpaFile(\n\trepo: string,\n\tfilename: string,\n\tdest: string,\n\tmodelKey: SttModelKey,\n\ttransport: SttTransport,\n\trequestId: string,\n): Promise<void> {\n\tconst url = `${HF_RESOLVE_BASE}/${repo}/resolve/main/${filename}`;\n\tconst response = await fetch(url, { redirect: \"follow\" });\n\tif (!response.ok || !response.body) {\n\t\tthrow new Error(`Failed to download ${filename} (${repo}): HTTP ${response.status}`);\n\t}\n\tconst total = Number(response.headers.get(\"content-length\") ?? 0);\n\ttransport.send({\n\t\ttype: \"progress\",\n\t\tid: requestId,\n\t\tevent: { modelKey, status: \"download\", name: `${repo}/${filename}`, file: filename },\n\t});\n\tconst part = `${dest}.part`;\n\tconst handle = await fs.open(part, \"w\");\n\tlet loaded = 0;\n\tlet lastEmitted = 0;\n\tconst reader = response.body.getReader();\n\ttry {\n\t\tfor (;;) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\t\t\tif (!value) continue;\n\t\t\tawait handle.write(value);","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/stt/asr-worker.ts#L253-L289","documentation":"downloadSherpaFile fetches raw model files from the Hugging Face resolve endpoint (https://huggingface.co/<repo>/resolve/main/<filename>) with redirect following. Any non-OK HTTP status or a missing response body aborts the download with this error, which names the file, the repo, and the HTTP status code.","triggerScenarios":"Downloading a sherpa model file when Hugging Face returns 404 (file/repo renamed or removed), 401/403 (gated repo), 429 (rate limit), or 5xx, or when the response has no body stream.","commonSituations":"Model repo moved or deprecated upstream, corporate proxy/firewall intercepting the request, Hugging Face rate limiting, or offline/broken DNS causing an error page status.","solutions":["Check the reported HTTP status: 404 → verify the repo/filename still exists on Hugging Face; 401/403 → the repo may now be gated and require a token; 429 → wait and retry with backoff.","Check network/proxy connectivity to huggingface.co.","Retry the download later if it is a transient 5xx.","Pin/switch to a different STT model tier whose repo is still available."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const head = await fetch(url, { method: \"HEAD\", redirect: \"follow\" });\nif (!head.ok) throw new Error(`model file unavailable: ${url} (HTTP ${head.status})`);","typeGuard":null,"tryCatchPattern":"try { await downloadSherpaFile(...); } catch (err) { if (/HTTP (429|5..)/.test(String(err))) await Bun.sleep(backoff); /* retry with exponential backoff */ else throw err; }","preventionTips":["Verify the HF repo/file still exists before pinning a model tier.","Handle 429 with exponential backoff for rate limits.","Configure proxy/token settings if downloads happen in gated or corporate networks."],"tags":["network","http","download","huggingface"],"backgroundTag":"model-download-http-error","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}