unslothai/unsloth · error · NativePathLeaseError

Native path is no longer accessible.

Error message

Native path is no longer accessible.

What it means

os.lstat(path) on the grant's canonical_path raised OSError, so the signed file no longer exists or is not statable by the backend process. The lease re-stats the exact path that was signed before any read, precisely to catch files that vanished or became unreadable between selection and use.

Source

Thrown at studio/backend/utils/native_path_leases.py:190

    payload_b64, signature_b64 = _split_lease(lease)
    expected_signature = hmac.new(
        secret,
        payload_b64.encode("ascii"),
        hashlib.sha256,
    ).digest()
    supplied_signature = _b64decode(signature_b64)
    if not hmac.compare_digest(expected_signature, supplied_signature):
        raise NativePathLeaseError("Native path grant signature is invalid.")

    payload = _decode_payload(payload_b64)
    _validate_payload(payload, operation = operation, expected_kind = expected_kind)

    path = Path(str(payload["canonical_path"]))
    _reject_network_or_device_path(path)
    try:
        signed_lstat = os.lstat(path)
    except OSError as exc:
        raise NativePathLeaseError("Native path is no longer accessible.") from exc
    if _stat_module.S_ISLNK(signed_lstat.st_mode):
        raise NativePathLeaseError("Native path is no longer a regular file.")
    try:
        resolved = path.resolve(strict = True)
    except OSError as exc:
        raise NativePathLeaseError("Native path is no longer accessible.") from exc
    _reject_network_or_device_path(resolved)
    if not _same_native_path(resolved, path):
        raise NativePathLeaseError("Native path grant no longer resolves to the selected path.")

    identity_options = _identity_options(payload)
    grant = NativePathGrant(
        operation = str(payload["operation"]),
        canonical_path = resolved,
        path_kind = str(payload["path_kind"]),
        path_type = str(payload["path_type"]),
        source_kind = str(payload["source_kind"]),
        token_id_hash = str(payload["token_id_hash"]),

View on GitHub (pinned to 203007d190)

Solutions

  1. Re-select the file in the desktop dialog to obtain a fresh grant, then retry the operation.
  2. If the path is on removable media, verify the device is mounted and the path still exists before retrying.
  3. Check that the backend process (user, container, sandbox) has at least stat permission on the path — compare the user the Tauri shell runs the backend as.
  4. Keep the interval between grant issuance and use short so files are less likely to change underneath.

Example fix

# before
grant = verify_native_path_lease(lease, operation="read_gguf")

# after
try:
    grant = verify_native_path_lease(lease, operation="read_gguf")
except NativePathLeaseError as exc:
    if "no longer accessible" in str(exc):
        raise RetryableFilePickError("File vanished; ask the user to re-select it.") from exc
    raise
Defensive patterns

Strategy: retry

Validate before calling

import os

def path_probe(path_str: str) -> bool:
    try:
        os.lstat(path_str)
        return True
    except OSError:
        return False

Try / catch

try:
    grant = verify_native_path_lease(lease, operation=OP)
except NativePathLeaseError as exc:
    if "no longer accessible" in str(exc):
        prompt_user_to_reselect("The selected file is no longer available.")
        return
    raise

Prevention

When it happens

Trigger: The user deleted, moved, or renamed the file after picking it; an external drive/MTP device was unplugged or remounted; permissions changed so the backend process can no longer stat the path; the file lives on a mounted device whose mount disappeared; or the backend runs under a different user/container without filesystem access to that path.

Common situations: Long gaps between file selection and the actual import/export operation (grant expiry window), removable media (USB drives, phones via MTP), files on network shares that disconnected, or dev setups where the backend runs in Docker while the file picker ran on the host.

Related errors


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