{"record":{"id":"7b2733967b7a6dd0","repo":"can1357/oh-my-pi","slug":"failed-to-download-model-filename-from-rep","errorCode":null,"errorMessage":"Failed to download ${model} ${fileName} from ${repo}: ${response.status} ${response.statusText}","messagePattern":"Failed to download (.+?) (.+?) from (.+?): (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mnemopi/src/core/fastembed-model-cache.ts","lineNumber":32,"sourceCode":"\t\"fast-bge-small-en\": \"BAAI/bge-small-en\",\n\t\"fast-bge-small-en-v1.5\": \"BAAI/bge-small-en-v1.5\",\n\t\"fast-bge-small-zh-v1.5\": \"BAAI/bge-small-zh-v1.5\",\n\t\"fast-multilingual-e5-large\": \"intfloat/multilingual-e5-large\",\n};\n\n/** Download missing config/tokenizer sidecars into a fastembed model cache directory. */\nexport async function ensureFastembedModelSidecars(model: string, cacheDir = \"local_cache\"): Promise<boolean> {\n\tconst repo = FASTEMBED_HF_REPOS[model];\n\tif (repo === undefined) return false;\n\n\tconst modelDir = path.join(cacheDir, model);\n\tfor (const fileName of FASTEMBED_MODEL_SIDECARS) {\n\t\tconst target = path.join(modelDir, fileName);\n\t\tif (await Bun.file(target).exists()) continue;\n\n\t\tconst response = await fetch(`https://huggingface.co/${repo}/resolve/main/${fileName}`);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to download ${model} ${fileName} from ${repo}: ${response.status} ${response.statusText}`,\n\t\t\t);\n\t\t}\n\t\tawait Bun.write(target, await response.arrayBuffer());\n\t}\n\treturn true;\n}\n","sourceCodeStart":14,"sourceCodeEnd":40,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/mnemopi/src/core/fastembed-model-cache.ts#L14-L40","documentation":"ensureFastembedModelSidecars downloads missing model sidecar files (tokenizer/config) from Hugging Face and throws if any fetch returns a non-OK status, embedding the model, filename, repo, and HTTP status in the message. This is the sidecar-heal path for the local fastembed model cache.","triggerScenarios":"Initializing fastembed when a sidecar file is absent locally and `https://huggingface.co/<repo>/resolve/main/<file>` returns 401/403 (rate limit or gated repo), 404 (file/repo moved), or 5xx.","commonSituations":"Offline/air-gapped environments with a partial cache, Hugging Face rate limiting (429) anonymous downloads, model repos renamed or made gated, corporate proxies blocking huggingface.co.","solutions":["Pre-populate the model cache directory with all FASTEMBED_MODEL_SIDECARS files (copy from another machine) so no download is attempted.","Set a HF token if the repo is gated/rate-limited, or use an HF mirror endpoint if available.","Check the exact HTTP status in the message: 404 → repo/model renamed, update the fastembed package; 429 → retry later with backoff.","Verify network/proxy access to huggingface.co from the deployment environment."],"exampleFix":"// before\n// partial cache: model.onnx exists, tokenizer.json missing → runtime download fails offline\n// after\n// provision offline:\n// cp ~/.cache/fastembed/<model>/tokenizer.json /app/.cache/fastembed/<model>/\nawait initWithSidecarHeal(); // now no fetch needed","handlingStrategy":"fallback","validationCode":"for (const f of FASTEMBED_MODEL_SIDECARS) {\n  if (!(await Bun.file(path.join(modelDir, f)).exists())) {\n    throw new Error(`Cache incomplete before offline init: missing ${f}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await initWithSidecarHeal();\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Failed to download\")) {\n    // fall back to a non-sidecar embedding path or fail with setup instructions\n  } else throw e;\n}","preventionTips":["Pre-download all sidecars into the cache at deploy time (Docker build step).","Monitor the HTTP status in the message: 404 means the repo moved — upgrade fastembed.","Set HF auth token for gated repos and handle 429 with backoff.","Verify egress to huggingface.co in locked-down environments."],"tags":["network","download","huggingface","http","model-cache"],"backgroundTag":"model-download-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}