janhq/jan · error

Failed to fetch HuggingFace repository

Error message

Failed to fetch HuggingFace repository: ${response.status} ${response.statusText}

What it means

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).

Solutions

  1. Verify the repository id is correct (404 path means it simply doesn't exist)
  2. Add a HuggingFace access token for gated/private repos
  3. Wait and retry if rate limited (429)
  4. Check HuggingFace API status for outages

Example fix

// before
const info = await repoInfo('org/repo')
// after
const info = await repoInfo('org/repo', { token: process.env.HF_TOKEN })
if (info === null) console.warn('HF repo not found')
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(hfUrl)
if (res.status === 404) return null // treat as missing, not an error

Type guard

null

Try / catch

try { info = await fetchHuggingFaceRepo(id) } catch (e) { if (String(e).includes('429')) backoffAndRetry(); else throw e }

Prevention

When it happens

Trigger: repoInfo called with a HuggingFace repo id while the API returns 401/403/429/5xx — e.g. gated repo without token, or rate limiting.

Common situations: Accessing a gated/private repo without a HF token, hitting anonymous rate limits, or HuggingFace API outages.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/9b4399545ba4df1b. Report an issue: GitHub.

Appendix: source

Thrown at web-app/src/services/models/default.ts:132

        return null
      }

      const response = await fetch(
        `https://huggingface.co/api/models/${cleanRepoId}?blobs=true&files_metadata=true`,
        {
          headers: hfToken
            ? {
                Authorization: `Bearer ${hfToken}`,
              }
            : {},
        }
      )

      if (!response.ok) {
        if (response.status === 404) {
          return null // Repository not found
        }
        throw new Error(
          `Failed to fetch HuggingFace repository: ${response.status} ${response.statusText}`
        )
      }

      const repoData = await response.json()
      return repoData
    } catch (error) {
      console.error('Error fetching HuggingFace repository:', error)
      return null
    }
  }

  convertHfRepoToCatalogModel(repo: HuggingFaceRepo): CatalogModel {
    // Format file size helper
    const formatFileSize = (size?: number) => {
      if (!size) return 'Unknown size'
      if (size < 1024 ** 3) return `${(size / 1024 ** 2).toFixed(1)} MB`
      return `${(size / 1024 ** 3).toFixed(1)} GB`

View on GitHub (pinned to 7205d770c1)