{"record":{"id":"50cd74ba6822abc4","repo":"continuedev/continue","slug":"failed-to-fetch-ollama-library-response-status","errorCode":null,"errorMessage":"Failed to fetch Ollama library: ${response.status}","messagePattern":"Failed to fetch Ollama library: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/llm/fetchModels.ts","lineNumber":68,"sourceCode":"\nfunction getOllamaIcon(modelName: string): string {\n  if (OLLAMA_ICON_MAP[modelName]) {\n    return OLLAMA_ICON_MAP[modelName];\n  }\n  let bestMatch = \"\";\n  for (const prefix of Object.keys(OLLAMA_ICON_MAP)) {\n    if (modelName.startsWith(prefix) && prefix.length > bestMatch.length) {\n      bestMatch = prefix;\n    }\n  }\n  return bestMatch ? OLLAMA_ICON_MAP[bestMatch] : \"ollama.png\";\n}\n\nasync function fetchOllamaModels(): Promise<FetchedModel[]> {\n  try {\n    const response = await fetch(\"https://ollama.com/library\");\n    if (!response.ok) {\n      throw new Error(`Failed to fetch Ollama library: ${response.status}`);\n    }\n\n    const html = await response.text();\n    const models: FetchedModel[] = [];\n    const items = html.split(\"x-test-model class=\");\n    const seen = new Set<string>();\n\n    for (let i = 1; i < items.length; i++) {\n      const item = items[i];\n      const nameMatch = item.match(/href=\"\\/library\\/([^\"]+)\"/);\n      if (!nameMatch) continue;\n      const name = nameMatch[1];\n      if (seen.has(name)) continue;\n\n      const capabilities: string[] = [];\n      const capRegex = /x-test-capability[^>]*>([^<]+)</g;\n      let capMatch;\n      while ((capMatch = capRegex.exec(item)) !== null) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/fetchModels.ts#L50-L86","documentation":"Thrown by fetchOllamaModels when scraping https://ollama.com/library returns a non-OK HTTP status. The model-list page is fetched to enumerate available Ollama models; any non-200 response aborts with the status code in the message.","triggerScenarios":"The library page returns 403/404/5xx — site redesign breaking the scraper, rate limiting from frequent requests, or network middleboxes blocking ollama.com.","commonSituations":"Corporate proxies/firewalls blocking external sites; ollama.com changing its HTML or rejecting bot traffic; offline or restricted environments.","solutions":["Retry after a short delay in case of transient 5xx/rate limiting","Check network access: curl -I https://ollama.com/library from the same machine","If the site changed, update the library or pin a known-good version; fall back to manually listing installed models via `ollama list` (local /api/tags)"],"exampleFix":"// before\nconst models = await fetchModels(); // throws: 403\n// after\ntry {\n  const models = await fetchModels();\n} catch (e) {\n  const models = (await fetch(\"http://localhost:11434/api/tags\")).json().models.map(m => ({ name: m.name }));\n}","handlingStrategy":"retry","validationCode":"const ping = await fetch('https://ollama.com/library', { method: 'HEAD' }); if (!ping.ok) useLocalOllamaTagsInstead();","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.message.includes('Failed to fetch Ollama library')) { await backoff(); retry(); } else throw e; }","preventionTips":["Cache model lists","Rate-limit scraping-style fetches","Fall back to local `ollama list` for available models"],"tags":["ollama","network","http","model-list"],"backgroundTag":"http-request-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}