{"record":{"id":"9b4399545ba4df1b","repo":"janhq/jan","slug":"failed-to-fetch-huggingface-repository-response","errorCode":null,"errorMessage":"Failed to fetch HuggingFace repository: ${response.status} ${response.statusText}","messagePattern":"Failed to fetch HuggingFace repository: (.+?) (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"web-app/src/services/models/default.ts","lineNumber":132,"sourceCode":"        return null\n      }\n\n      const response = await fetch(\n        `https://huggingface.co/api/models/${cleanRepoId}?blobs=true&files_metadata=true`,\n        {\n          headers: hfToken\n            ? {\n                Authorization: `Bearer ${hfToken}`,\n              }\n            : {},\n        }\n      )\n\n      if (!response.ok) {\n        if (response.status === 404) {\n          return null // Repository not found\n        }\n        throw new Error(\n          `Failed to fetch HuggingFace repository: ${response.status} ${response.statusText}`\n        )\n      }\n\n      const repoData = await response.json()\n      return repoData\n    } catch (error) {\n      console.error('Error fetching HuggingFace repository:', error)\n      return null\n    }\n  }\n\n  convertHfRepoToCatalogModel(repo: HuggingFaceRepo): CatalogModel {\n    // Format file size helper\n    const formatFileSize = (size?: number) => {\n      if (!size) return 'Unknown size'\n      if (size < 1024 ** 3) return `${(size / 1024 ** 2).toFixed(1)} MB`\n      return `${(size / 1024 ** 3).toFixed(1)} GB`","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/web-app/src/services/models/default.ts#L114-L150","documentation":"fetchHuggingFaceRepo queries the HuggingFace API for repository metadata; 404 returns null (repo not found), but any other non-OK status throws. It distinguishes 'missing repo' from 'request failed' (auth, rate limit, server error).","triggerScenarios":"repoInfo called with a HuggingFace repo id while the API returns 401/403/429/5xx — e.g. gated repo without token, or rate limiting.","commonSituations":"Accessing a gated/private repo without a HF token, hitting anonymous rate limits, or HuggingFace API outages.","solutions":["Verify the repository id is correct (404 path means it simply doesn't exist)","Add a HuggingFace access token for gated/private repos","Wait and retry if rate limited (429)","Check HuggingFace API status for outages"],"exampleFix":"// before\nconst info = await repoInfo('org/repo')\n// after\nconst info = await repoInfo('org/repo', { token: process.env.HF_TOKEN })\nif (info === null) console.warn('HF repo not found')","handlingStrategy":"try-catch","validationCode":"const res = await fetch(hfUrl)\nif (res.status === 404) return null // treat as missing, not an error","typeGuard":"null","tryCatchPattern":"try { info = await fetchHuggingFaceRepo(id) } catch (e) { if (String(e).includes('429')) backoffAndRetry(); else throw e }","preventionTips":["Configure a HuggingFace token for gated repos","Respect rate limits with backoff","Distinguish 404 (missing) from other statuses"],"tags":["huggingface","http","api"],"backgroundTag":"api-error-response","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}