{"record":{"id":"59268fcbba413968","repo":"unslothai/unsloth","slug":"selected-cached-model-is-no-longer-available","errorCode":null,"errorMessage":"Selected cached model is no longer available.","messagePattern":"Selected cached model is no longer available\\.","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"studio/backend/routes/models.py","lineNumber":2125,"sourceCode":"\ndef _model_config_inspection_target(\n    model_name: str, prefer_local_cache: bool, local_path: Optional[str]\n) -> str:\n    if not prefer_local_cache or is_local_path(model_name):\n        return model_name\n    from hub.utils.hf_cache_state import (\n        latest_snapshot_from_cache_path,\n        with_load_subdirs,\n    )\n\n    snapshot = latest_snapshot_from_cache_path(\n        local_path,\n        \"model\",\n        canonical_model_repo_id(model_name),\n        with_load_subdirs(model_name, (\"config.json\", \"adapter_config.json\")),\n    )\n    if snapshot is None:\n        raise HTTPException(\n            status_code = 404,\n            detail = \"Selected cached model is no longer available.\",\n        )\n    return snapshot\n\n\n@router.get(\"/config/{model_name:path}\")\nasync def get_model_config(\n    model_name: str,\n    hf_token: Optional[str] = Query(None),\n    prefer_local_cache: bool = False,\n    local_path: Optional[str] = None,\n    header_hf_token: Optional[str] = Depends(get_hf_token),\n    current_subject: str = Depends(get_current_subject),\n):\n    \"\"\"Get configuration for a specific model (wraps load_model_defaults).\"\"\"\n    hf_token = _normalize_hf_token(header_hf_token) or _normalize_hf_token(hf_token)\n    from core.inference.llama_cpp import _hf_offline_if_unreachable_for","sourceCodeStart":2107,"sourceCodeEnd":2143,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/models.py#L2107-L2143","documentation":"Raised as a 404 by the model-config helper when latest_snapshot_from_cache_path() cannot find a usable HF-hub snapshot for the requested model under the given local_path. It means the model cache entry the user selected previously no longer resolves to a loadable snapshot (missing config.json/adapter_config.json or the snapshot directory vanished).","triggerScenarios":"GET /api/models/config/{model_name}?local_path=...&prefer_local_cache=true where the HF cache snapshot directory was deleted, pruned (huggingface-cli delete-cache), partially downloaded, or the expected config.json / adapter_config.json files are absent from every candidate snapshot under with_load_subdirs.","commonSituations":"Cache cleanup tools removing snapshots; interrupted downloads leaving partial snapshots; multi-revision caches where the 'latest' snapshot lacks the needed config; repo id casing mismatch in canonical_model_repo_id.","solutions":["Re-download the model snapshot (huggingface-cli download <repo_id>) so the cache contains config.json/adapter_config.json again.","Inspect local_path/snapshots to confirm a complete snapshot directory exists for canonical_model_repo_id(model_name).","If the cache was intentionally pruned, clear the stale selection in the UI and re-pick the model so local_path points at a valid entry.","Fall back to fetching config from the Hub (drop prefer_local_cache / local_path)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef snapshot_complete(local_path: str, repo_id: str) -> bool:\n    snaps = Path(local_path).expanduser() / 'snapshots'\n    if not snaps.is_dir():\n        return False\n    return any(\n        (s / 'config.json').is_file() or (s / 'adapter_config.json').is_file()\n        for s in snaps.iterdir() if s.is_dir()\n    )\n\nif not snapshot_complete(local_path, model_name):\n    raise FileNotFoundError('cached snapshot missing configs — re-download before requesting config')","typeGuard":null,"tryCatchPattern":"try:\n    cfg = client.get(f'/api/models/config/{model}', params={'local_path': lp, 'prefer_local_cache': True})\nexcept HTTPError as e:\n    if e.response.status_code == 404 and 'no longer available' in e.response.json()['detail']:\n        cfg = client.get(f'/api/models/config/{model}')  # fall back to Hub fetch\n    else: raise","preventionTips":["Verify snapshot directories contain config.json/adapter_config.json before selecting them.","Treat cache-prune operations as invalidating saved local_path selections.","Keep a Hub fallback path in the client when prefer_local_cache is used."],"tags":["models","huggingface","cache","not-found","local-models"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}