{"record":{"id":"e978d82817c914f4","repo":"unslothai/unsloth","slug":"repo-is-gated-on-hugging-face-and-this-model-c","errorCode":null,"errorMessage":"'{repo}' is gated on Hugging Face and this model cannot be downloaded without it. Accept its licence at {url}, then add a Hugging Face token that has access in Studio settings and try again.","messagePattern":"'(.+?)' is gated on Hugging Face and this model cannot be downloaded without it\\. Accept its licence at (.+?), then add a Hugging Face token that has access in Studio settings and try again\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/diffusion.py","lineNumber":701,"sourceCode":"                    return True\n        except Exception:  # noqa: BLE001 — a cache we cannot read is not an access verdict\n            pass\n        return False\n\n    def _is_auth_error(exc: Any) -> bool:\n        \"\"\"A 401/403 that hf_raise_for_status did not classify: an expired token 401s \"Invalid\n        credentials in Authorization header\", which _http.py excludes from its RepoNotFound branch\n        by name, and a token missing a permission 403s. Both arrive as plain HfHubHTTPError, so\n        catching only the classified errors fails open on the very case this probe exists to catch.\"\"\"\n        status = getattr(getattr(exc, \"response\", None), \"status_code\", None)\n        return status in (401, 403)\n\n    try:\n        gated = getattr(HfApi().model_info(repo, token = hf_token), \"gated\", None)\n    except GatedRepoError:  # a gated repo can also withhold its metadata\n        if _already_downloaded():\n            return other_root_snapshot\n        raise ValueError(_repo_access_message(repo, gated = True)) from None\n    except RepositoryNotFoundError as exc:\n        # 401 and 404 both land here: hf_raise_for_status folds unauthenticated private/gated in\n        # with a missing repo because \"401 is misleading\" (_http.py), so re-read the status. A\n        # 401/403 earns the cache escape; a genuine 404, or an error carrying no response, raises.\n        if _is_auth_error(exc) and _already_downloaded():\n            return other_root_snapshot\n        raise ValueError(_repo_access_message(repo, gated = False)) from None\n    except HfHubHTTPError as exc:\n        if not _is_auth_error(exc):\n            return None  # a 5xx or rate limit is not an access verdict\n        if _already_downloaded():\n            return other_root_snapshot\n        raise ValueError(_repo_access_message(repo, gated = False)) from None\n    except Exception:  # noqa: BLE001 — offline / transient: the download surfaces any real error\n        return None\n    # Nothing to carry: model_info answered, so the size estimate lists the base files and the\n    # prefetch resolves each through whichever root holds it.\n    if not gated or _already_downloaded():","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion.py#L683-L719","documentation":"Raised from the HF access probe when HfApi().model_info(repo) raises GatedRepoError (or a later metadata HEAD on the probe file does): the base repo requires accepting a licence on Hugging Face, and the request's token either lacks acceptance or was made without one. The probe escapes to a cached snapshot when the model is already fully downloaded, otherwise it fails with this actionable message.","triggerScenarios":"Loading a diffusion model whose base repo (often resolved from a card tag) is gated, e.g. FLUX or similar, without having accepted its licence; token present but licence acceptance missing; no token configured at all for a gated repo.","commonSituations":"First-time use of a newly released gated model; a fresh Studio install with no HF token in settings; token from an account that never accepted the specific model's licence; licence acceptance reset.","solutions":["Open the repo URL shown in the message in a browser, log in, and accept the licence","Add a Hugging Face token belonging to that account in Studio settings, then retry","If the model was previously downloaded, verify the local snapshot is complete so the probe can use the cache escape"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def can_access_repo(repo: str, token: str | None) -> bool:\n    from huggingface_hub import HfApi, GatedRepoError\n    try:\n        info = HfApi().model_info(repo, token=token)\n        return not getattr(info, \"gated\", False)\n    except GatedRepoError:\n        return False\n    except Exception:\n        return True  # let the download surface the real error","typeGuard":null,"tryCatchPattern":"try:\n    load_diffusion_model(cfg)\nexcept ValueError as e:\n    if \"gated on Hugging Face\" in str(e):\n        show(url_in(e), action=\"accept licence + set token\")","preventionTips":["Accept gated-model licences in the browser before first load","Keep a valid HF token with the needed access in Studio settings","Fully download gated models once so later loads can use the local snapshot"],"tags":["diffusion","huggingface","gated-repo","auth","network"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}