astrid-runtime/astrid · error

kernel returned an unexpected storage mount response

Error message

kernel returned an unexpected storage mount response

What it means

This error is thrown by `lease_from_response` in the WinFsp storage provider when the kernel's admin response to a storage mount request is neither a `StorageMountLease` nor an `Error` variant of `AdminResponseBody`. It signals a protocol mismatch: the provider received a well-formed response envelope but of an unexpected kind, so it cannot extract the mount lease. This guards against desynchronizing the local filesystem state from the kernel's actual mount state.

Source

Thrown at crates/astrid-storage-provider-winfsp/src/main.rs:307

        )?;
    }
    update_registry(|registry| {
        registry.mounts.remove(&path_key(&record.mountpoint)?);
        Ok(())
    })?;
    if record.auto_created_mountpoint {
        let _ = std::fs::remove_dir(&record.mountpoint);
    }
    Ok(StorageProviderSuccessV1::Unmounted {
        mount_id: record.mount_id,
    })
}

fn lease_from_response(body: AdminResponseBody) -> Result<StorageMountLeaseV1> {
    match body {
        AdminResponseBody::StorageMountLease(lease) => Ok(*lease),
        AdminResponseBody::Error(error) => bail!("kernel refused storage mount: {error}"),
        _ => bail!("kernel returned an unexpected storage mount response"),
    }
}

fn into_success(body: AdminResponseBody) -> Result<serde_json::Value> {
    match body {
        AdminResponseBody::Success(value) => Ok(value),
        AdminResponseBody::Error(error) => {
            bail!("kernel refused storage lifecycle request: {error}")
        },
        _ => bail!("kernel returned an unexpected storage lifecycle response"),
    }
}

fn unmount_status(body: AdminResponseBody) -> Result<bool> {
    match body {
        AdminResponseBody::Success(_) => Ok(true),
        AdminResponseBody::Error(error)
            if error.contains("was not found") || error.contains("expired or revoked") =>

View on GitHub (pinned to affd8760f4)

Solutions

  1. Upgrade or downgrade the astrid-storage-provider-winfsp provider so its version matches the running kernel's admin API
  2. Check the kernel logs to see what response body was actually returned for the mount request
  3. Verify the mount request is being sent to the correct admin endpoint that returns a StorageMountLease

Example fix

// before: match on only two variants
match body {
    AdminResponseBody::StorageMountLease(lease) => Ok(*lease),
    AdminResponseBody::Error(error) => bail!("kernel refused storage mount: {error}"),
    _ => bail!("kernel returned an unexpected storage mount response"),
}
// after: handle the new variant explicitly
match body {
    AdminResponseBody::StorageMountLease(lease) => Ok(*lease),
    AdminResponseBody::StorageMountLeaseV2(lease) => Ok(lease.into_v1()),
    AdminResponseBody::Error(error) => bail!("kernel refused storage mount: {error}"),
    _ => bail!("kernel returned an unexpected storage mount response"),
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust: no pre-call validation of the response variant is possible; verify provider/kernel version compatibility before mounting
fn versions_compatible(provider: &str, kernel: &str) -> bool { /* compare admin API versions */ true }

Type guard

fn is_mount_lease(body: &AdminResponseBody) -> bool {
    matches!(body, AdminResponseBody::StorageMountLease(_) | AdminResponseBody::Error(_))
}

Try / catch

match provider.mount(request).await {
    Ok(lease) => use_lease(lease),
    Err(e) if e.to_string().contains("unexpected storage mount response") => {
        // version skew: log and surface an upgrade hint
        log::error!("kernel/provider admin API mismatch: {e}");
    },
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling `mount` when the kernel replies to the storage mount admin request with an `AdminResponseBody` variant other than `StorageMountLease` or `Error` — e.g. a plain `Success` value or any newer/other response type the provider does not recognize.

Common situations: Running a kernel (astrald) version that emits a different response schema than the provider expects; a version skew between provider and kernel after an API change; routing the mount request to the wrong admin endpoint that returns a generic success payload.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/8ba4e2d7f9ffdcfe. Report an issue: GitHub.