unslothai/unsloth · warning · HTTPException

Path does not exist: {os.path.basename(requested_path)}

Error message

Path does not exist: {os.path.basename(requested_path)}

What it means

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.

Source

Thrown at studio/backend/routes/models.py:1681

            resolved = root.resolve()
        except OSError:
            continue
        key = str(resolved)
        if key in seen_roots:
            continue
        seen_roots.add(key)
        resolved_roots.append(resolved)

    for root in resolved_roots:
        parts = _browse_relative_parts(requested_path, root)
        if parts is None:
            continue

        current = root
        for part in parts:
            child = _match_browse_child(current, part)
            if child is None:
                raise HTTPException(
                    status_code = 404,
                    detail = f"Path does not exist: {os.path.basename(requested_path)}",
                )
            try:
                resolved_child = child.resolve()
            except OSError as exc:
                logger.warning(
                    "browse-folders: invalid path component %r under %s: %s",
                    part,
                    current,
                    exc,
                    exc_info = True,
                )
                raise HTTPException(
                    status_code = 400,
                    detail = "Invalid path",
                ) from exc
            if not _is_path_inside_allowlist(resolved_child, resolved_roots):

View on GitHub (pinned to 203007d190)

Solutions

  1. Re-list the parent directory in the browser UI and re-select the target — the tree will reflect current disk state.
  2. Verify the exact spelling/case of every path segment against the filesystem.
  3. If a root was moved, update the scan-folder registration via POST /api/models/scan-folders to the new location.
Defensive patterns

Strategy: try-catch

Validate before calling

import os

def path_exists_under(root: str, rel: str) -> bool:
    cur = root
    for part in rel.strip('/').split('/'):
        cur = os.path.join(cur, part)
        if not os.path.exists(cur):
            return False
    return True

Try / catch

try:
    entries = browse(path)
except HTTPError as e:
    if e.response.status_code == 404:
        refresh_tree_to_parent(path)  # stale node — re-list parent and re-navigate
    else: raise

Prevention

When it happens

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

Common situations: Folder renamed/moved/deleted while the browse dialog was open; typo in a manually entered path; drive contents changed underneath a cached tree.

Related errors


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