{"record":{"id":"2fa1fc27187b4361","repo":"unslothai/unsloth","slug":"path-does-not-exist","errorCode":null,"errorMessage":"Path does not exist","messagePattern":"Path does not exist","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"studio/backend/core/rag/folder_sync.py","lineNumber":135,"sourceCode":"\n\ndef _is_within(root: str, path: str) -> bool:\n    try:\n        return os.path.normcase(os.path.commonpath([root, path])) == os.path.normcase(root)\n    except ValueError:\n        return False\n\n\ndef validate_folder_path(path: str) -> str:\n    \"\"\"Apply the existing model scan-folder policy without persisting there.\"\"\"\n    if not path or not path.strip() or \"\\x00\" in path:\n        raise ValueError(\"Path cannot be empty\")\n    expanded = os.path.abspath(os.path.expanduser(path))\n    try:\n        if stat.S_ISLNK(os.lstat(expanded).st_mode):\n            raise ValueError(\"Symbolic-link folders are not allowed\")\n    except OSError as exc:\n        raise ValueError(\"Path does not exist\") from exc\n    normalized = os.path.realpath(expanded)\n    uploads_root = os.path.realpath(str(rag_uploads_root()))\n    if _paths_overlap(_path_key(normalized), _path_key(uploads_root)):\n        raise ValueError(\"The managed RAG uploads folder cannot be linked\")\n\n    from hub.storage.scan_folders import (\n        contains_sensitive_path_component,\n        is_denied_system_path,\n    )\n    from utils.paths.external_media import is_local_filesystem_root\n\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        raise ValueError(\"The filesystem root cannot be registered\")\n    try:","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/rag/folder_sync.py#L117-L153","documentation":"ValueError raised when os.lstat on the expanded path raises OSError — i.e. the path (or its parent during lstat) does not exist or is not accessible. It wraps the underlying OSError, so errno distinguishes ENOENT (missing) from EACCES (permission denied on a parent) and similar. It fires before any content policy checks because a nonexistent folder cannot be validated or scanned.","triggerScenarios":"Calling validate_folder_path on a typo'd path, a path on an unmounted drive/network share, a removable drive that is unplugged, or a parent directory the user cannot traverse.","commonSituations":"USB/external drives registered then unplugged; network mounts (SMB/NFS) not yet mounted at app start; typos in manually typed paths; paths copied from another machine that don't exist here.","solutions":["Verify the path exists: ls the exact expanded string (remember ~ expansion and case-sensitivity on Linux).","Mount the external/network volume before registering the folder.","Check traverse permission on every parent directory (chmod +x) if lstat failed with EACCES."],"exampleFix":"# before\nvalidate_folder_path('/mnt/share/docs')  # share not mounted\n\n# after\nimport os\npath = '/mnt/share/docs'\nif not os.path.exists(path):\n    raise SystemExit(f'mount {path} first')\nvalidate_folder_path(path)","handlingStrategy":"validation","validationCode":"import os\n\ndef folder_exists(path: str) -> bool:\n    expanded = os.path.abspath(os.path.expanduser(path))\n    return os.path.exists(expanded)","typeGuard":null,"tryCatchPattern":"try:\n    validate_folder_path(path)\nexcept ValueError as e:\n    if str(e) != \"Path does not exist\":\n        raise\n    return bad_request(f\"folder not found: {path!r} — check mounts and spelling\")","preventionTips":["Auto-complete/suggest existing paths in the UI to prevent typos.","Verify external and network volumes are mounted before batch registration jobs run.","Handle removable-media links gracefully: warn at sync time instead of hard-failing."],"tags":["paths","filesystem","validation","mounts"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}