{"record":{"id":"6817d95729f5f396","repo":"unslothai/unsloth","slug":"native-path-is-no-longer-accessible","errorCode":null,"errorMessage":"Native path is no longer accessible.","messagePattern":"Native path is no longer accessible\\.","errorType":"validation","errorClass":"NativePathLeaseError","httpStatus":400,"severity":"error","filePath":"studio/backend/utils/native_path_leases.py","lineNumber":190,"sourceCode":"    payload_b64, signature_b64 = _split_lease(lease)\n    expected_signature = hmac.new(\n        secret,\n        payload_b64.encode(\"ascii\"),\n        hashlib.sha256,\n    ).digest()\n    supplied_signature = _b64decode(signature_b64)\n    if not hmac.compare_digest(expected_signature, supplied_signature):\n        raise NativePathLeaseError(\"Native path grant signature is invalid.\")\n\n    payload = _decode_payload(payload_b64)\n    _validate_payload(payload, operation = operation, expected_kind = expected_kind)\n\n    path = Path(str(payload[\"canonical_path\"]))\n    _reject_network_or_device_path(path)\n    try:\n        signed_lstat = os.lstat(path)\n    except OSError as exc:\n        raise NativePathLeaseError(\"Native path is no longer accessible.\") from exc\n    if _stat_module.S_ISLNK(signed_lstat.st_mode):\n        raise NativePathLeaseError(\"Native path is no longer a regular file.\")\n    try:\n        resolved = path.resolve(strict = True)\n    except OSError as exc:\n        raise NativePathLeaseError(\"Native path is no longer accessible.\") from exc\n    _reject_network_or_device_path(resolved)\n    if not _same_native_path(resolved, path):\n        raise NativePathLeaseError(\"Native path grant no longer resolves to the selected path.\")\n\n    identity_options = _identity_options(payload)\n    grant = NativePathGrant(\n        operation = str(payload[\"operation\"]),\n        canonical_path = resolved,\n        path_kind = str(payload[\"path_kind\"]),\n        path_type = str(payload[\"path_type\"]),\n        source_kind = str(payload[\"source_kind\"]),\n        token_id_hash = str(payload[\"token_id_hash\"]),","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/native_path_leases.py#L172-L208","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-select the file in the desktop dialog to obtain a fresh grant, then retry the operation.","If the path is on removable media, verify the device is mounted and the path still exists before retrying.","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.","Keep the interval between grant issuance and use short so files are less likely to change underneath."],"exampleFix":"# before\ngrant = verify_native_path_lease(lease, operation=\"read_gguf\")\n\n# after\ntry:\n    grant = verify_native_path_lease(lease, operation=\"read_gguf\")\nexcept NativePathLeaseError as exc:\n    if \"no longer accessible\" in str(exc):\n        raise RetryableFilePickError(\"File vanished; ask the user to re-select it.\") from exc\n    raise","handlingStrategy":"retry","validationCode":"import os\n\ndef path_probe(path_str: str) -> bool:\n    try:\n        os.lstat(path_str)\n        return True\n    except OSError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    grant = verify_native_path_lease(lease, operation=OP)\nexcept NativePathLeaseError as exc:\n    if \"no longer accessible\" in str(exc):\n        prompt_user_to_reselect(\"The selected file is no longer available.\")\n        return\n    raise","preventionTips":["Keep the time between file selection and use short; grants expire anyway.","For removable media, lstat the path right before submitting the request.","Surface re-select prompts to users instead of silent failures.","Don't run the backend in a container if the picker runs on the host."],"tags":["filesystem","removable-media","stat","stale-state"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}