unslothai/unsloth · warning · ValueError

Path does not exist

Error message

Path does not exist

What it means

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.

Source

Thrown at studio/backend/core/rag/folder_sync.py:135


def _is_within(root: str, path: str) -> bool:
    try:
        return os.path.normcase(os.path.commonpath([root, path])) == os.path.normcase(root)
    except ValueError:
        return False


def validate_folder_path(path: str) -> str:
    """Apply the existing model scan-folder policy without persisting there."""
    if not path or not path.strip() or "\x00" in path:
        raise ValueError("Path cannot be empty")
    expanded = os.path.abspath(os.path.expanduser(path))
    try:
        if stat.S_ISLNK(os.lstat(expanded).st_mode):
            raise ValueError("Symbolic-link folders are not allowed")
    except OSError as exc:
        raise ValueError("Path does not exist") from exc
    normalized = os.path.realpath(expanded)
    uploads_root = os.path.realpath(str(rag_uploads_root()))
    if _paths_overlap(_path_key(normalized), _path_key(uploads_root)):
        raise ValueError("The managed RAG uploads folder cannot be linked")

    from hub.storage.scan_folders import (
        contains_sensitive_path_component,
        is_denied_system_path,
    )
    from utils.paths.external_media import is_local_filesystem_root

    if not os.path.isdir(normalized):
        raise ValueError("Path must be a directory, not a file")
    if not os.access(normalized, os.R_OK | os.X_OK):
        raise ValueError("Path is not readable")
    if is_local_filesystem_root(normalized):
        raise ValueError("The filesystem root cannot be registered")
    try:

View on GitHub (pinned to 203007d190)

Solutions

  1. Verify the path exists: ls the exact expanded string (remember ~ expansion and case-sensitivity on Linux).
  2. Mount the external/network volume before registering the folder.
  3. Check traverse permission on every parent directory (chmod +x) if lstat failed with EACCES.

Example fix

# before
validate_folder_path('/mnt/share/docs')  # share not mounted

# after
import os
path = '/mnt/share/docs'
if not os.path.exists(path):
    raise SystemExit(f'mount {path} first')
validate_folder_path(path)
Defensive patterns

Strategy: validation

Validate before calling

import os

def folder_exists(path: str) -> bool:
    expanded = os.path.abspath(os.path.expanduser(path))
    return os.path.exists(expanded)

Try / catch

try:
    validate_folder_path(path)
except ValueError as e:
    if str(e) != "Path does not exist":
        raise
    return bad_request(f"folder not found: {path!r} — check mounts and spelling")

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/2fa1fc27187b4361. Report an issue: GitHub.