unslothai/unsloth · error · NativePathLeaseError
Native path grant kind is invalid.
Error message
Native path grant kind is invalid.
What it means
expected_kind was passed to verify_native_path_lease() and the payload's path_kind doesn't match it. path_kind distinguishes what the grant is for (e.g. a picked single 'file' vs a 'document-folder' selection); endpoints restrict it so a folder-selection grant can't be used where only file-kind grants are valid, independent of path_type.
Source
Thrown at studio/backend/utils/native_path_leases.py:325
"operation",
"canonical_path",
"path_kind",
"path_type",
"source_kind",
"token_id_hash",
"issued_at_ms",
"expires_at_ms",
"nonce",
)
missing = [key for key in required if key not in payload]
if missing:
raise NativePathLeaseError("Native path grant payload is missing required fields.")
if _required_int(payload, "version") != 1:
raise NativePathLeaseError("Native path grant version is unsupported.")
if payload["operation"] != operation:
raise NativePathLeaseError("Native path grant operation is invalid.")
if expected_kind and payload["path_kind"] != expected_kind:
raise NativePathLeaseError("Native path grant kind is invalid.")
now_ms = int(time.time() * 1000)
issued_at_ms = _required_int(payload, "issued_at_ms")
expires_at_ms = _required_int(payload, "expires_at_ms")
if issued_at_ms >= expires_at_ms:
raise NativePathLeaseError("Native path grant timestamps are inconsistent.")
if expires_at_ms <= now_ms:
raise NativePathLeaseError("Native path grant has expired.")
if issued_at_ms > now_ms + 30_000:
raise NativePathLeaseError("Native path grant issue time is invalid.")
for key in ("canonical_path", "nonce", "token_id_hash", "display_label"):
raw = payload.get(key)
if raw is None:
continue
if "\x00" in str(raw):
raise NativePathLeaseError("Native path grant contains invalid characters.")
def _validate_current_stat(View on GitHub (pinned to 203007d190)
Solutions
- Use the picker flow whose selection kind matches the endpoint's expected_kind and obtain a new grant from it.
- Align path_kind literals between the Rust signer and each backend call site via shared constants.
- Store leases keyed by (dialog, kind) in the frontend so a folder grant never reaches a file-only endpoint.
- For test signers, emit exactly the path_kind the verifier expects.
Example fix
# before lease = await pick_document_folder() verify_native_path_lease(lease, operation="load_weights", expected_kind="file") # after lease = await pick_native_file() verify_native_path_lease(lease, operation="load_weights", expected_kind="file")
Defensive patterns
Strategy: validation
Validate before calling
# Frontend: bind each lease to the picker kind it came from
if stored_lease.kind !== EXPECTED_KIND: throw new Error('wrong selection kind'); Try / catch
try:
grant = verify_native_path_lease(lease, operation=OP, expected_kind="file")
except NativePathLeaseError as exc:
if "kind is invalid" in str(exc):
return error_response(400, "This action needs a different kind of selection.")
raise Prevention
- Namespace stored leases by (operation, kind).
- Share path_kind literals as constants across Rust and Python.
- Configure the picker for the exact kind the endpoint expects before opening the dialog.
When it happens
Trigger: Calling an endpoint expecting path_kind='file' with a grant from a document-folder picker (or vice versa); frontend mixing leases from a folder-scoped selection flow into a single-file API; test signers emitting an arbitrary path_kind value that the verifier's expected_kind rejects.
Common situations: UI flows that let users pick either a folder or a file but funnel both into the same submit handler; refactors renaming kind identifiers on one side; new sidecar features (e.g. mtp/dspark companion dirs) tightening expected_kind after grants were already issued under the old kind.
Related errors
- Native path grant has the wrong path type.
- Unknown model_kind '{model_kind}'. Expected one of {sorted(_
- Linked folders support only knowledge-base and project scope
- Native path grant is required.
- Native path grant has an unsupported file type.
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/695a2c80da5da737.
Report an issue: GitHub.