{"record":{"id":"c4880e9bc8d914c3","repo":"unslothai/unsloth","slug":"path-does-not-exist-c4880e","errorCode":null,"errorMessage":"Path does not exist","messagePattern":"Path does not exist","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"warning","filePath":"studio/backend/hub/storage/scan_folders.py","lineNumber":125,"sourceCode":"    conn = get_connection()\n    try:\n        _ensure_schema(conn)\n        rows = conn.execute(\n            \"SELECT id, path, created_at FROM scan_folders ORDER BY created_at\"\n        ).fetchall()\n        return [dict(row) for row in rows]\n    finally:\n        conn.close()\n\n\ndef add_scan_folder_with_status(path: str) -> tuple[dict, bool]:\n    \"\"\"Add a readable scan folder and return its row plus whether it was inserted.\"\"\"\n    if not path or not path.strip():\n        raise ValueError(\"Path cannot be empty\")\n    normalized = os.path.realpath(os.path.expanduser(normalize_path(path.strip())))\n\n    if not os.path.exists(normalized):\n        raise ValueError(\"Path does not exist\")\n    if not os.path.isdir(normalized):\n        raise ValueError(\"Path must be a directory, not a file\")\n    if not os.access(normalized, os.R_OK | os.X_OK):\n        raise ValueError(\"Path is not readable\")\n    if is_local_filesystem_root(normalized):\n        # A local fs root (\"/\", \"C:\\\\\") would expose denied system dirs via browse;\n        # a UNC share root (\\\\server\\share) has none under it and stays registerable.\n        raise ValueError(\"The filesystem root cannot be registered\")\n    if _contains_sensitive_path_component(normalized):\n        raise ValueError(\"Credential or configuration directories are not allowed\")\n\n    is_win = platform.system() == \"Windows\"\n    check = os.path.normcase(normalized) if is_win else normalized\n    for prefix in _denied_path_prefixes():\n        if check == prefix or check.startswith(prefix + os.sep):\n            if prefix == \"/run\" and is_linux_run_media_path(check):\n                continue\n            raise ValueError(f\"Path under {prefix} is not allowed\")","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/hub/storage/scan_folders.py#L107-L143","documentation":"Validation error from add_scan_folder_with_status: the normalized path (after expanduser + realpath) does not exist on disk. realpath does not require existence, so this check catches typos, moved directories, and unmounted volumes before they enter the scan-folders DB.","triggerScenarios":"Registering a folder that was deleted/renamed; a typo like /dat/models instead of /data/models; a mount point whose volume is not mounted; using ~user for a user that does not exist.","commonSituations":"External drive unplugged; NAS share not mounted at boot before studio starts; paths copy-pasted from another machine.","solutions":["Verify the path exists as the same user the backend runs as: `sudo -u <backend-user> ls <path>`.","Fix typos in the submitted path.","Mount the volume first, then register the folder."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\n\ndef folder_exists(path: str) -> bool:\n    return os.path.isdir(os.path.realpath(os.path.expanduser(path.strip())))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the folder exists as the backend service user before registering it.","Register folders only after their volume is mounted (e.g. after the mount unit, in systemd After=).","Re-check existence on UI load since folders can disappear between sessions."],"tags":["validation","scan-folders","filesystem"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}