{"record":{"id":"980fec905bab297f","repo":"unslothai/unsloth","slug":"could-not-read-os-path-basename-str-current","errorCode":null,"errorMessage":"Could not read {os.path.basename(str(current))}","messagePattern":"Could not read (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"studio/backend/routes/models.py","lineNumber":1644,"sourceCode":"        if part == \"..\" or os.sep in part or (altsep and altsep in part):\n            return None\n    return parts\n\n\ndef _match_browse_child(current: Path, name: str) -> Optional[Path]:\n    \"\"\"Return the immediate child named ``name`` under ``current``.\"\"\"\n    try:\n        for child in current.iterdir():\n            if child.name == name:\n                return child\n    except PermissionError:\n        raise HTTPException(\n            status_code = 403,\n            detail = f\"Permission denied reading {current.name}\",\n        ) from None\n    except OSError as exc:\n        logger.warning(\"browse-folders: could not read %s: %s\", current, exc, exc_info = True)\n        raise HTTPException(\n            status_code = 500,\n            detail = f\"Could not read {os.path.basename(str(current))}\",\n        ) from exc\n    return None\n\n\ndef _resolve_browse_target(path: Optional[str], allowed_roots: list[Path]) -> Path:\n    \"\"\"Resolve a requested browse path by walking from trusted allowlist roots.\"\"\"\n    from storage.studio_db import (\n        contains_sensitive_path_component,\n        is_denied_system_path,\n    )\n\n    requested_path = _normalize_browse_request_path(path)\n    resolved_roots: list[Path] = []\n    seen_roots: set[str] = set()\n    for root in sorted(allowed_roots, key = lambda p: len(str(p)), reverse = True):\n        try:","sourceCodeStart":1626,"sourceCodeEnd":1662,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/models.py#L1626-L1662","documentation":"Raised as a 500 by _match_browse_child when iterdir() on an intermediate directory fails with a non-permission OSError while the backend walks toward the requested browse path. The full exception is logged with exc_info; the client gets a generic basename-only message so raw OS errors are not leaked.","triggerScenarios":"Browsing a path that traverses an unresponsive network share, a disconnected mapped drive, a stale NFS mount, or a directory deleted mid-walk; ENOENT/EIO/EMFILE-class errors during the component-by-component walk.","commonSituations":"Mapped drive disconnected on Windows; NFS/SMB server down or timing out; antivirus or filesystem corruption causing EIO; race between directory listing and deletion.","solutions":["Check the backend logs — the warning line includes the exact directory and OS error.","Restore the mount/share (reconnect the drive, remount NFS/SMB) and retry.","If a directory was removed, refresh the front-end tree from the allowlist root and re-navigate.","Register a scan folder closer to the data so the walk avoids the failing intermediate directory."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import os\n\ndef mount_alive(d: str) -> bool:\n    try:\n        os.statvfs(d); return True\n    except OSError:\n        return False\n\nif not mount_alive(models_dir):\n    show_user('Storage for this folder is offline — reconnect it, then retry.')","typeGuard":null,"tryCatchPattern":"try:\n    entries = browse(path)\nexcept HTTPError as e:\n    if e.response.status_code == 500 and 'Could not read' in e.response.json()['detail']:\n        return fallback_to_cached_entries(path)  # show last-known tree, offer retry\n    raise","preventionTips":["Watch backend logs for 'browse-folders: could not read' — it carries the real errno.","Use stable local storage for model directories; avoid mounts that sleep/disconnect.","Cache the last successful listing in the UI so an offline share degrades gracefully."],"tags":["filesystem","os-error","network-share","browse","models"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}