{"record":{"id":"cf14bb96f9314a13","repo":"astrid-runtime/astrid","slug":"kernel-refused-storage-unmount-authorization-err-cf14bb","errorCode":null,"errorMessage":"kernel refused storage unmount authorization: {error}","messagePattern":"kernel refused storage unmount authorization: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/main.rs","lineNumber":330,"sourceCode":"    match body {\n        AdminResponseBody::Success(value) => Ok(value),\n        AdminResponseBody::Error(error) => {\n            bail!(\"kernel refused storage lifecycle request: {error}\")\n        },\n        _ => bail!(\"kernel returned an unexpected storage lifecycle response\"),\n    }\n}\n\nfn unmount_status(body: AdminResponseBody) -> Result<bool> {\n    match body {\n        AdminResponseBody::Success(_) => Ok(true),\n        AdminResponseBody::Error(error)\n            if error.contains(\"was not found\") || error.contains(\"expired or revoked\") =>\n        {\n            Ok(false)\n        },\n        AdminResponseBody::Error(error) => {\n            bail!(\"kernel refused storage unmount authorization: {error}\")\n        },\n        _ => bail!(\"kernel returned an unexpected storage unmount response\"),\n    }\n}\n\n#[cfg(windows)]\nfn prepare_mountpoint(\n    requested: Option<PathBuf>,\n    view: &astrid_core::storage_provider::StorageProviderViewV1,\n) -> Result<(PathBuf, bool)> {\n    let _ = view;\n    let mountpoint = requested.map_or_else(first_free_drive, Ok)?;\n    if !mountpoint.is_absolute() {\n        bail!(\"mountpoint must be absolute\");\n    }\n    if is_drive_target(&mountpoint) {\n        if std::fs::metadata(&mountpoint).is_ok() {\n            bail!(","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/main.rs#L312-L348","documentation":"`unmount_status` checks with the kernel whether a mount lease is still valid before unmounting. Errors containing 'was not found' or 'expired or revoked' are treated as 'already unmounted' (returns `Ok(false)`); any other kernel error is surfaced here as a hard refusal, preserving the kernel's message. This distinguishes benign already-gone states from genuine authorization failures.","triggerScenarios":"`unmount` calls `unmount_status` and the kernel returns `AdminResponseBody::Error` whose text does NOT contain 'was not found' or 'expired or revoked' — e.g. permission denied on the lease, malformed lease id, or kernel-internal errors.","commonSituations":"Unmounting a volume whose lease belongs to another identity/tenant; sending a corrupted or wrong lease reference; kernel experiencing internal errors during lease validation.","solutions":["Inspect the embedded kernel error text for the actual refusal cause","Confirm the lease id and identity used for the unmount request are correct and authorized","If the lease truly no longer exists, ensure the error text matches the expected 'was not found' phrasing or upgrade provider/kernel so phrasing stays in sync"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match provider.unmount(lease).await {\n    Ok(true) => log::info!(\"unmounted\"),\n    Ok(false) => log::info!(\"already unmounted (lease gone/expired)\"),\n    Err(e) if e.to_string().contains(\"refused storage unmount authorization\") => {\n        // check identity/lease correctness before retrying\n    },\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Use the same identity/tenant that created the lease when unmounting","Keep lease references intact; don't hand-edit or truncate lease ids","Treat Ok(false) as success in idempotent cleanup paths"],"tags":["ipc","authorization","unmount","winfsp"],"backgroundTag":"permission-denied","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}