{"record":{"id":"8a99aa2682c669b1","repo":"unslothai/unsloth","slug":"path-does-not-exist-os-path-basename-requested-p","errorCode":null,"errorMessage":"Path does not exist: {os.path.basename(requested_path)}","messagePattern":"Path does not exist: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"studio/backend/routes/models.py","lineNumber":1681,"sourceCode":"            resolved = root.resolve()\n        except OSError:\n            continue\n        key = str(resolved)\n        if key in seen_roots:\n            continue\n        seen_roots.add(key)\n        resolved_roots.append(resolved)\n\n    for root in resolved_roots:\n        parts = _browse_relative_parts(requested_path, root)\n        if parts is None:\n            continue\n\n        current = root\n        for part in parts:\n            child = _match_browse_child(current, part)\n            if child is None:\n                raise HTTPException(\n                    status_code = 404,\n                    detail = f\"Path does not exist: {os.path.basename(requested_path)}\",\n                )\n            try:\n                resolved_child = child.resolve()\n            except OSError as exc:\n                logger.warning(\n                    \"browse-folders: invalid path component %r under %s: %s\",\n                    part,\n                    current,\n                    exc,\n                    exc_info = True,\n                )\n                raise HTTPException(\n                    status_code = 400,\n                    detail = \"Invalid path\",\n                ) from exc\n            if not _is_path_inside_allowlist(resolved_child, resolved_roots):","sourceCodeStart":1663,"sourceCodeEnd":1699,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/models.py#L1663-L1699","documentation":"Raised as a 404 by _resolve_browse_target when, while walking component-by-component from an allowlist root, a requested path segment has no matching child in the current directory (_match_browse_child returns None). This means the requested path looked plausible relative to a root, but some component along the way does not exist on disk.","triggerScenarios":"GET browse-folders?path=... where any intermediate or final segment is misspelled or was deleted; the front-end tree is stale and references a folder renamed or removed after it was listed.","commonSituations":"Folder renamed/moved/deleted while the browse dialog was open; typo in a manually entered path; drive contents changed underneath a cached tree.","solutions":["Re-list the parent directory in the browser UI and re-select the target — the tree will reflect current disk state.","Verify the exact spelling/case of every path segment against the filesystem.","If a root was moved, update the scan-folder registration via POST /api/models/scan-folders to the new location."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os\n\ndef path_exists_under(root: str, rel: str) -> bool:\n    cur = root\n    for part in rel.strip('/').split('/'):\n        cur = os.path.join(cur, part)\n        if not os.path.exists(cur):\n            return False\n    return True","typeGuard":null,"tryCatchPattern":"try:\n    entries = browse(path)\nexcept HTTPError as e:\n    if e.response.status_code == 404:\n        refresh_tree_to_parent(path)  # stale node — re-list parent and re-navigate\n    else: raise","preventionTips":["Re-list a parent after renames/deletes before navigating deeper.","Treat folder-picker state as ephemeral; never cache paths across sessions without revalidating.","Handle 404 by collapsing the stale node in the tree, not by showing a raw error."],"tags":["filesystem","not-found","browse","models","stale-state"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}