{"record":{"id":"88e27f7f4e482f68","repo":"unslothai/unsloth","slug":"choose-a-cache-folder","errorCode":null,"errorMessage":"Choose a cache folder.","messagePattern":"Choose a cache folder\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/utils/hf_cache_settings.py","lineNumber":245,"sourceCode":"    # default while routing cache bytes through the selected home.\n    if not os.environ.get(\"HF_HOME\", \"\").strip():\n        os.environ[\"HF_HOME\"] = str(_default_cache_home())\n    os.environ[\"HF_HUB_CACHE\"] = str(paths.hub_cache)\n    os.environ[\"HF_XET_CACHE\"] = str(paths.xet_cache)\n    if \"HUGGINGFACE_HUB_CACHE\" not in _EXPLICIT_CACHE_ENV:\n        os.environ.pop(\"HUGGINGFACE_HUB_CACHE\", None)\n    for directory in (paths.hub_cache, paths.xet_cache):\n        try:\n            directory.mkdir(parents = True, exist_ok = True)\n        except OSError:\n            pass\n    return paths\n\n\ndef _validate_cache_home(raw_path: str) -> Path:\n    value = raw_path.strip()\n    if not value:\n        raise ValueError(\"Choose a cache folder.\")\n    candidate = Path(value).expanduser()\n    if not candidate.is_absolute():\n        raise ValueError(\"The Hugging Face cache folder must be an absolute path.\")\n    try:\n        resolved = candidate.resolve(strict = False)\n    except (OSError, RuntimeError, ValueError) as exc:\n        raise ValueError(\"The Hugging Face cache folder is invalid.\") from exc\n\n    if resolved.parent == resolved:\n        raise ValueError(\"Choose a folder inside the filesystem or drive root.\")\n    try:\n        from hub.storage.scan_folders import (\n            contains_sensitive_path_component,\n            is_denied_system_path,\n        )\n    except ImportError:\n        contains_sensitive_path_component = is_denied_system_path = None\n    if is_denied_system_path is not None and is_denied_system_path(str(resolved)):","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/hf_cache_settings.py#L227-L263","documentation":"Raised by _validate_cache_home when the configured Hugging Face cache folder string is empty after stripping. This is the first, most basic guard in a chain (empty → absolute → resolvable → not filesystem root → not a sensitive/denied system path). The short message reflects a UI-style prompt ('Choose a cache folder.') because the value is typically set from a settings form.","triggerScenarios":"Calling the cache-home setter/API with '', '   ', or a value that strips to empty — e.g. a form submitted with the field cleared, or a config key present but blank.","commonSituations":"User clears the cache-folder field in settings to 'unset' it (the API expects omission, not blank); YAML/JSON config with cache_home: \"\"; trailing whitespace-only values pasted from a form.","solutions":["Provide a real absolute path such as /home/user/.cache/huggingface or D:\\\\hf-cache.","To unset/reset, use the dedicated reset path (or remove the setting) rather than saving an empty string.","Trim the input client-side and treat blank as 'no change'.","If set via env/config file, delete the blank key entirely."],"exampleFix":"# before\nset_cache_home(\"   \")  # ValueError: Choose a cache folder.\n\n# after\nset_cache_home(\"/mnt/data/hf-cache\")","handlingStrategy":"validation","validationCode":"def is_nonblank_path(raw) -> bool:\n    return isinstance(raw, str) and bool(raw.strip())","typeGuard":"def is_settable_cache_home(value) -> bool:\n    \"\"\"Non-blank string; further checks (absolute, safe) happen server-side.\"\"\"\n    return isinstance(value, str) and len(value.strip()) > 0","tryCatchPattern":null,"preventionTips":["Treat blank cache-folder submissions as 'no change', not as a save.","Use the dedicated reset/unset action instead of saving an empty string.","Use a folder picker that always yields an absolute path.","Omit empty keys from config files rather than writing \"\"."],"tags":["settings","hf-cache","path-validation","config"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}