{"record":{"id":"7fee472767df1de1","repo":"unslothai/unsloth","slug":"path-cannot-be-empty-7fee47","errorCode":null,"errorMessage":"Path cannot be empty","messagePattern":"Path cannot be empty","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"studio/backend/routes/rag.py","lineNumber":295,"sourceCode":"    try:\n        grant = verify(\n            native_path_lease,\n            operation = \"link-documents\",\n            expected_kind = \"document-folder\",\n            expected_path_type = \"directory\",\n        )\n        device_id = getattr(grant, \"device_id\", None)\n        file_id = getattr(grant, \"file_id\", None)\n        if device_id is None or file_id is None:\n            raise NativePathLeaseError(\"Native folder grant has no stable identity.\")\n        return (\n            folder_sync.validate_folder_path(str(grant.canonical_path)),\n            (device_id, file_id),\n        )\n    except NativePathLeaseError as exc:\n        raise HTTPException(status_code = 400, detail = str(exc)) from exc\n    except ValueError as exc:\n        raise HTTPException(status_code = 400, detail = str(exc)) from exc\n\n\ndef _folder_view(row: dict) -> dict:\n    status = (\n        \"syncing\"\n        if row[\"status\"] == \"syncing\"\n        else \"error\"\n        if row[\"status\"] in {\"error\", \"retired\"}\n        else \"idle\"\n    )\n    return {\n        \"id\": row[\"id\"],\n        \"displayName\": row[\"name\"],\n        \"scopeType\": row[\"scope_type\"],\n        \"scopeId\": row[\"scope_id\"],\n        \"status\": status,\n        \"error\": row.get(\"last_error\"),\n        \"lastSyncedAt\": row.get(\"last_scan_at\"),","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/rag.py#L277-L313","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nlink_folder(lease_for='            ')  # whitespace path -> 400 Path cannot be empty\n# after\nlink_folder(lease_for='/home/user/Documents/research')  # real directory","handlingStrategy":"validation","validationCode":"import os\np = path.strip()\nassert p and '\\x00' not in p and os.path.isdir(os.path.realpath(os.path.expanduser(p))), 'pick a real directory'\nassert not os.path.islink(os.path.abspath(os.path.expanduser(p))), 'symlinked folders are rejected'","typeGuard":"const plausibleFolderPath = (p: string): boolean =>\n  p.trim().length > 0 && !p.includes('\\0') && !p.endsWith('/');","tryCatchPattern":"if (res.status === 400) { showFolderPolicyError(detail); /* detail names the exact policy violated */ }","preventionTips":["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."],"tags":["http-400","linked-folder","path-validation","rag","studio-backend"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}