{"record":{"id":"629701cb15d852b4","repo":"astrid-runtime/astrid","slug":"detached-fuse-service-returned-a-mismatched-lease","errorCode":null,"errorMessage":"detached FUSE service returned a mismatched lease identity","messagePattern":"detached FUSE service returned a mismatched lease identity","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/astrid-storage-provider-fuse/src/main.rs","lineNumber":255,"sourceCode":"        })\n        .await?;\n    let lease = lease_from_response(body)?;\n    let control_path = registry::control_path(&lease.mount_id)?;\n    let launch = ServiceLaunch {\n        lease: lease.clone(),\n        requested_by: acting_principal,\n        mountpoint: mountpoint.clone(),\n        auto_created_mountpoint: auto_created,\n    };\n    let startup = launch_service(&launch, &control_path).await;\n    let ready = match startup {\n        Ok(ready) => ready,\n        Err(error) => {\n            return Err(rollback_mount_error(error, client, &launch, &control_path).await);\n        },\n    };\n    if ready.mount_id != lease.mount_id || ready.access != lease.access {\n        let error = anyhow::anyhow!(\"detached FUSE service returned a mismatched lease identity\");\n        return Err(rollback_mount_error(error, client, &launch, &control_path).await);\n    }\n    if ready.pid == 0 {\n        let error = anyhow::anyhow!(\"detached FUSE service returned an invalid process identity\");\n        return Err(rollback_mount_error(error, client, &launch, &control_path).await);\n    }\n    let control_ready = call_control(\n        &control_path,\n        &ControlRequest::Status {\n            requested_by: launch.requested_by.clone(),\n        },\n    )\n    .and_then(|response| require_ready_control_response(response, lease.access));\n    if let Err(error) = control_ready {\n        let error = error.context(\"detached FUSE service failed its readiness handshake\");\n        return Err(rollback_mount_error(error, client, &launch, &control_path).await);\n    }\n    let record = registry::MountRecord {","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-fuse/src/main.rs#L237-L273","documentation":"After launching the detached FUSE service, the parent reads the service's Ready reply and verifies that the mount_id and access mode match the StorageMountLeaseV1 it granted. A mismatch means the reply did not correspond to this launch — a protocol or identity corruption — so the mount is rolled back via rollback_mount_error. This protects against mounting with the wrong lease (wrong tenant or access level).","triggerScenarios":"call_launch -> detached service responds with Ready whose mount_id != lease.mount_id or access != lease.access; caused by stale control sockets, a reused launch file, or a service binary at a different version replying with foreign identity data.","commonSituations":"Concurrent mounts overwriting each other's launch/control paths in a shared temp dir; stale sockets from a previous crashed run; version skew between host and provider binary.","solutions":["Ensure each detached launch uses a unique, freshly created launch/control path per mount.","Kill and remove stale service processes and sockets from prior runs before remounting.","Align host and provider binary versions so the Ready payload schema matches.","Retry the mount after cleanup; the rollback has already released the bad mount."],"exampleFix":"// before\nlet control_path = std::env::temp_dir().join(\"astrid-fuse-control\");\n// after\nlet control_path = std::env::temp_dir().join(format!(\"astrid-fuse-control-{}\", uuid::Uuid::new_v4()));","handlingStrategy":"validation","validationCode":"fn ready_matches(ready: &Ready, lease: &StorageMountLeaseV1) -> bool {\n    ready.mount_id == lease.mount_id && ready.access == lease.access\n}","typeGuard":"fn is_valid_ready(ready: &Ready, lease: &StorageMountLeaseV1) -> bool {\n    ready.mount_id == lease.mount_id\n        && ready.access == lease.access\n        && ready.pid != 0\n}","tryCatchPattern":"if ready.mount_id != lease.mount_id || ready.access != lease.access {\n    let error = anyhow::anyhow!(\"detached FUSE service returned a mismatched lease identity\");\n    return Err(rollback_mount_error(error, client, &launch, &control_path).await);\n}","preventionTips":["Use a unique per-mount launch/control path (e.g. UUID suffix) to avoid cross-talk between concurrent mounts.","Clean up stale sockets and launch files from crashed runs before remounting.","Keep host and provider binaries version-aligned so Ready payloads match the expected schema."],"tags":["fuse","protocol","lease","rollback","security"],"backgroundTag":"internal-invariant-violation","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}