unslothai/unsloth · warning · HTTPException
Path cannot be empty
Error message
Path cannot be empty
What it means
In the linked-folder flow, _resolve_linked_folder_path() calls folder_sync.validate_folder_path() on the granted canonical path; that function raises ValueError('Path cannot be empty') when the path is empty, whitespace-only, or contains a NUL byte. The route's generic except ValueError handler maps it to HTTP 400 with the validator's message. validate_folder_path applies the model scan-folder policy (no symlinks, must be a readable non-root, non-sensitive directory, not the uploads root).
Source
Thrown at studio/backend/routes/rag.py:295
try:
grant = verify(
native_path_lease,
operation = "link-documents",
expected_kind = "document-folder",
expected_path_type = "directory",
)
device_id = getattr(grant, "device_id", None)
file_id = getattr(grant, "file_id", None)
if device_id is None or file_id is None:
raise NativePathLeaseError("Native folder grant has no stable identity.")
return (
folder_sync.validate_folder_path(str(grant.canonical_path)),
(device_id, file_id),
)
except NativePathLeaseError as exc:
raise HTTPException(status_code = 400, detail = str(exc)) from exc
except ValueError as exc:
raise HTTPException(status_code = 400, detail = str(exc)) from exc
def _folder_view(row: dict) -> dict:
status = (
"syncing"
if row["status"] == "syncing"
else "error"
if row["status"] in {"error", "retired"}
else "idle"
)
return {
"id": row["id"],
"displayName": row["name"],
"scopeType": row["scope_type"],
"scopeId": row["scope_id"],
"status": status,
"error": row.get("last_error"),
"lastSyncedAt": row.get("last_scan_at"),View on GitHub (pinned to 203007d190)
Solutions
- Select an explicit, non-empty local directory path and re-issue the lease for it.
- If the detail is a different validate_folder_path message, follow it: remove symlinks from the path, avoid home/root/system/credential directories, ensure read+execute permission.
- Update the desktop bridge if canonical_path is being emitted empty.
Example fix
# before link_folder(lease_for=' ') # whitespace path -> 400 Path cannot be empty # after link_folder(lease_for='/home/user/Documents/research') # real directory
Defensive patterns
Strategy: validation
Validate before calling
import os p = path.strip() assert p and '\x00' not in p and os.path.isdir(os.path.realpath(os.path.expanduser(p))), 'pick a real directory' assert not os.path.islink(os.path.abspath(os.path.expanduser(p))), 'symlinked folders are rejected'
Type guard
const plausibleFolderPath = (p: string): boolean =>
p.trim().length > 0 && !p.includes('\0') && !p.endsWith('/'); Try / catch
if (res.status === 400) { showFolderPolicyError(detail); /* detail names the exact policy violated */ } Prevention
- Read the detail: the same handler maps every validate_folder_path rule (symlink, root, home, sensitive, not-a-dir, unreadable).
- Filter folder pickers to local directories with read+execute permission.
- Never link the managed uploads folder or credential/system directories.
When it happens
Trigger: Linking a folder whose resolved path is empty or whitespace after lease verification — a degenerate lease grant, or upstream code passing grant.canonical_path when it is blank. Other ValueError messages from the same validator (symlink, does not exist, not a directory, not readable, root/home/sensitive/system path, uploads-root overlap) surface through the identical handler.
Common situations: Bridge bug produces an empty canonical_path; user selects a path like '/dev/null' style specials; broader validation failures from selecting ~/.ssh, filesystem root, or the managed uploads folder itself.
Related errors
- Native folder grant has no stable identity.
- Linked folders support only knowledge-base and project scope
- Unsupported file type '{ext}'. Allowed: {sorted(config.UPLOA
- Uploaded file is empty.
- Native path grant is required.
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/7fee472767df1de1.
Report an issue: GitHub.