can1357/oh-my-pi · error · Error

Failed to download ${model} ${fileName} from ${repo}: ${resp

Error message

Failed to download ${model} ${fileName} from ${repo}: ${response.status} ${response.statusText}

What it means

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.

Source

Thrown at packages/mnemopi/src/core/fastembed-model-cache.ts:32

	"fast-bge-small-en": "BAAI/bge-small-en",
	"fast-bge-small-en-v1.5": "BAAI/bge-small-en-v1.5",
	"fast-bge-small-zh-v1.5": "BAAI/bge-small-zh-v1.5",
	"fast-multilingual-e5-large": "intfloat/multilingual-e5-large",
};

/** Download missing config/tokenizer sidecars into a fastembed model cache directory. */
export async function ensureFastembedModelSidecars(model: string, cacheDir = "local_cache"): Promise<boolean> {
	const repo = FASTEMBED_HF_REPOS[model];
	if (repo === undefined) return false;

	const modelDir = path.join(cacheDir, model);
	for (const fileName of FASTEMBED_MODEL_SIDECARS) {
		const target = path.join(modelDir, fileName);
		if (await Bun.file(target).exists()) continue;

		const response = await fetch(`https://huggingface.co/${repo}/resolve/main/${fileName}`);
		if (!response.ok) {
			throw new Error(
				`Failed to download ${model} ${fileName} from ${repo}: ${response.status} ${response.statusText}`,
			);
		}
		await Bun.write(target, await response.arrayBuffer());
	}
	return true;
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Pre-populate the model cache directory with all FASTEMBED_MODEL_SIDECARS files (copy from another machine) so no download is attempted.
  2. Set a HF token if the repo is gated/rate-limited, or use an HF mirror endpoint if available.
  3. Check the exact HTTP status in the message: 404 → repo/model renamed, update the fastembed package; 429 → retry later with backoff.
  4. Verify network/proxy access to huggingface.co from the deployment environment.

Example fix

// before
// partial cache: model.onnx exists, tokenizer.json missing → runtime download fails offline
// after
// provision offline:
// cp ~/.cache/fastembed/<model>/tokenizer.json /app/.cache/fastembed/<model>/
await initWithSidecarHeal(); // now no fetch needed
Defensive patterns

Strategy: fallback

Validate before calling

for (const f of FASTEMBED_MODEL_SIDECARS) {
  if (!(await Bun.file(path.join(modelDir, f)).exists())) {
    throw new Error(`Cache incomplete before offline init: missing ${f}`);
  }
}

Try / catch

try {
  await initWithSidecarHeal();
} catch (e) {
  if (e instanceof Error && e.message.startsWith("Failed to download")) {
    // fall back to a non-sidecar embedding path or fail with setup instructions
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/7b2733967b7a6dd0. Report an issue: GitHub.