{"record":{"id":"50f0c865ae5cd20c","repo":"unslothai/unsloth","slug":"no-safetensors-gguf-lora-file-found-in-repo-id","errorCode":null,"errorMessage":"no .safetensors/.gguf LoRA file found in '{repo_id}'","messagePattern":"no \\.safetensors/\\.gguf LoRA file found in '(.+?)'","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_lora.py","lineNumber":284,"sourceCode":"\ndef _pick_repo_weight_file(repo_id: str, hf_token: Optional[str]) -> str:\n    \"\"\"Pick the single LoRA weight file in an HF repo (prefer safetensors).\"\"\"\n    from huggingface_hub import HfApi\n\n    files = HfApi(token = hf_token).list_repo_files(repo_id)\n    safes = [f for f in files if f.lower().endswith(\".safetensors\") and \"/\" not in f]\n    if len(safes) == 1:\n        return safes[0]\n    # Prefer a lora-hinting filename, else the first safetensors, else a gguf.\n    for f in safes:\n        if \"lora\" in f.lower():\n            return f\n    if safes:\n        return safes[0]\n    ggufs = [f for f in files if f.lower().endswith(\".gguf\") and \"/\" not in f]\n    if ggufs:\n        return ggufs[0]\n    raise FileNotFoundError(f\"no .safetensors/.gguf LoRA file found in '{repo_id}'\")\n\n\ndef _scrub_hub_url(msg: str) -> str:\n    \"\"\"Strip embedded http(s) URLs from a Hub error message before it hits a 400 body.\"\"\"\n    cleaned = re.sub(r\"https?://\\S+\", \"\", msg)\n    # Collapse the whitespace the URL removal leaves behind.\n    return re.sub(r\"\\s{2,}\", \" \", cleaned).strip()\n\n\ndef resolve_specs(\n    specs: list[tuple[str, float]],\n    *,\n    family: Optional[str] = None,\n    hf_token: Optional[str] = None,\n    cancel_event: Optional[threading.Event] = None,\n) -> list[ResolvedLora]:\n    \"\"\"Resolve request (id, weight) pairs, dropping zero-weight entries.\n","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_lora.py#L266-L302","documentation":"Raised by the LoRA resolver when scanning a Hugging Face repo's file listing yields no top-level .safetensors or .gguf file suitable as a LoRA adapter. The resolver only considers files at the repo root (paths without '/'), so adapters nested in subfolders never qualify. It is a FileNotFoundError so callers can map it to a 4xx via the Hub-error handler in resolve_specs.","triggerScenarios":"Calling resolve/download of a LoRA spec whose repo_id contains only subfolder weights (e.g. 'some-org/lora-pack/subdir/adapter.safetensors' layout), only non-weight files (README, .bin, .pt), or is empty. Also triggered by mistyping a repo id that resolves to a non-adapter repo.","commonSituations":"User pastes a diffusers-format LoRA repo where the adapter lives under a subfolder; repo uses .bin or .pt format only; repo id points at a base model rather than a LoRA; HF returned an empty file list due to a truncated listing.","solutions":["Verify the repo actually contains a top-level .safetensors or .gguf file (huggingface-cli ls or the HF web UI)","If the adapter is nested in a subfolder, download it locally and point the spec at the local file path instead of the repo id","Convert .bin/.pt LoRA weights to .safetensors (safetensors convert or automatic1111 conversion scripts)","Check the repo id for typos and confirm it is a LoRA adapter repo, not a base model"],"exampleFix":"// before\nspecs = [(\"user/nested-lora\", 0.8)]  // adapter lives in nested-lora/adapter_model.safetensors\n// after\nspecs = [(\"user/nested-lora/resolve/main/adapter_model.safetensors\", 0.8)]\n// or download locally and pass the local path","handlingStrategy":"validation","validationCode":"from huggingface_hub import list_repo_files\n\ndef has_root_lora(repo_id: str) -> bool:\n    files = list_repo_files(repo_id)\n    root = [f for f in files if \"/\" not in f]\n    return any(f.lower().endswith((\".safetensors\", \".gguf\")) for f in root)","typeGuard":null,"tryCatchPattern":"try:\n    resolve_specs([...])\nexcept FileNotFoundError as e:\n    # map to 400 with the (already hub-url-scrubbed) message\n    return JSONResponse(status_code=400, content={\"detail\": str(e)})","preventionTips":["Validate the repo contains a top-level .safetensors/.gguf before queueing a LoRA load","Prefer safetensors-format LoRA repos; convert .bin adapters","Cache resolved adapter filenames to avoid re-listing large repos"],"tags":["lora","huggingface","file-not-found","diffusion"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}