unslothai/unsloth · error · RuntimeError

{label} unavailable for {repo_id}

Error message

{label} unavailable for {repo_id}

What it means

Terminal error in _retry_metadata_fetch (hf_download worker): fetching Hugging Face metadata (model_info/dataset_info) failed on both attempts — first with a short timeout, then a retry after _METADATA_RETRY_DELAY with a longer timeout — and the second attempt's exception was already re-raised inside the loop. This final raise is a defensive unreachable-in-practice branch; in practice you see the underlying exception (network error, HTTPError for a missing/gated repo, token failure), not this message. If this string ever surfaces, it means fetch() returned without returning (misbehaving fetch callable).

Source

Thrown at studio/backend/hub/workers/hf_download.py:203


def _hf_token_arg(hf_token: str | None) -> HfTokenArg:
    return hf_token if hf_token else False


def _retry_metadata_fetch(repo_id: str, fetch, *, label: str):
    for attempt, timeout in enumerate((_METADATA_REQUEST_TIMEOUT, _METADATA_RETRY_TIMEOUT)):
        try:
            return fetch(timeout)
        except Exception as e:
            if attempt == 1:
                raise
            print(
                f"{label} request failed for {repo_id} " f"({type(e).__name__}: {e}); retrying.",
                file = sys.stderr,
            )
            time.sleep(_METADATA_RETRY_DELAY)
    raise RuntimeError(f"{label} unavailable for {repo_id}")


def _model_info_with_retry(repo_id: str, hf_token: str | None):
    from huggingface_hub import model_info as hf_model_info
    return _retry_metadata_fetch(
        repo_id,
        lambda timeout: hf_model_info(
            repo_id,
            token = _hf_token_arg(hf_token),
            timeout = timeout,
            files_metadata = True,
        ),
        label = "Metadata",
    )


def _dataset_info_with_retry(repo_id: str, hf_token: str | None):
    from huggingface_hub import HfApi

View on GitHub (pinned to 203007d190)

Solutions

  1. Reproduce the metadata call directly: `python -c "from huggingface_hub import model_info; model_info('<repo_id>')"` — the real error surfaces there.
  2. For auth/gated errors, set a valid token with access (huggingface-cli login / HF_TOKEN) and accept the model's license on the Hub.
  3. For network errors, fix connectivity/proxy (HTTPS_PROXY), or check https://status.huggingface.co for outages.
  4. Confirm the repo_id exists and is spelled correctly (owner/name).

Example fix

# before: repo_id='meta-llama/Llama-3-8b' (gated, no token)
# after
export HF_TOKEN=hf_xxx   # token for an account that accepted the license
python -c "from huggingface_hub import model_info; print(model_info('meta-llama/Llama-3-8b', token=True))"
Defensive patterns

Strategy: retry

Validate before calling

import socket, urllib.request

def hub_reachable(timeout: float = 5.0) -> bool:
    try:
        urllib.request.urlopen("https://huggingface.co/api/whoami-v2", timeout=timeout)
        return True
    except Exception:
        return False

def repo_exists(repo_id: str, token: str | None = None) -> bool:
    from huggingface_hub import model_info
    try:
        model_info(repo_id, token=token, timeout=10)
        return True
    except Exception:
        return False

Try / catch

from huggingface_hub.utils import HfHubHTTPError
for attempt in range(3):
    try:
        info = _model_info_with_retry(repo_id, token)
        break
    except HfHubHTTPError as e:
        if e.response.status_code == 429 and attempt < 2:
            time.sleep(2 ** attempt * 5)  # rate-limited: back off and retry
            continue
        if e.response.status_code in (401, 403):
            raise RuntimeError(f"access denied for {repo_id}: check HF token / gated license")
        raise
    except (ConnectionError, TimeoutError):
        if attempt < 2:
            continue
        raise RuntimeError(f"hub unreachable for {repo_id}: check network/proxy")

Prevention

When it happens

Trigger: Worker downloading a model whose metadata call keeps failing: offline/blocked network, HuggingFace Hub outage or rate-limiting (429), nonexistent repo_id (401/404), or a gated repo with a missing/invalid token. The retryable path prints '<label> request failed for <repo> ...; retrying.' to stderr first.

Common situations: Air-gapped or proxied environments where huggingface.co is unreachable; expired HF token or gated model (Llama etc.) without accepted license; repo renamed/deleted after the job was queued; DNS failures in containers.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/9c95e07378c1e76c. Report an issue: GitHub.