astrid-runtime/astrid · error

kernel returned an unexpected storage mount response

Error message

kernel returned an unexpected storage mount response

What it means

lease_from_response() expects the kernel to answer a mount request with AdminResponseBody::StorageMountLease. Any other non-Error variant means the kernel replied with an unexpected response shape, so the companion bails rather than proceeding without a valid lease.

Source

Thrown at crates/astrid-storage-provider-fskit/src/main.rs:293

    })
}

fn authorize_stale_cleanup(
    lease_is_live: bool,
    requested_by: &astrid_core::PrincipalId,
    acting_principal: &astrid_core::PrincipalId,
) -> Result<()> {
    if !lease_is_live && requested_by != acting_principal {
        bail!("stale mount recovery belongs to another acting principal");
    }
    Ok(())
}

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. Ensure the kernel and companion are built from matching versions so response variants line up
  2. Inspect the admin channel for proxies/transformations altering the response body
  3. Capture and log the actual AdminResponseBody variant received to confirm the protocol mismatch

Example fix

// before
let lease = lease_from_response(body)?; // unexpected variant, unclear why
// after
log::debug!("kernel response variant: {:?}", std::mem::discriminant(&body));
let lease = lease_from_response(body)?;
Defensive patterns

Strategy: type-guard

Type guard

// rust
fn is_storage_mount_lease(body: &AdminResponseBody) -> bool {
    matches!(body, AdminResponseBody::StorageMountLease(_))
}

Try / catch

// rust
if !is_storage_mount_lease(&body) {
    eprintln!("unexpected kernel response for mount: {body:?}");
    // check kernel/companion version skew before retrying
}

Prevention

When it happens

Trigger: mount() receives an AdminResponseBody that is neither StorageMountLease nor Error — e.g. a Success or unrelated variant caused by a protocol/request-type mismatch between companion and kernel.

Common situations: Version-skewed kernel that responds with a different body type for mount requests; routing bug in the kernel admin channel returning the wrong variant; a proxy or wrapper intercepting and reshaping responses.

Related errors


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