{"record":{"id":"f0d3fb402ca42f79","repo":"astrid-runtime/astrid","slug":"mountpoint-is-already-registered-f0d3fb","errorCode":null,"errorMessage":"mountpoint is already registered: {}","messagePattern":"mountpoint is already registered: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/main.rs","lineNumber":189,"sourceCode":"            })\n        },\n        StorageProviderOperationV1::Unmount { selector } => {\n            unmount(&mut client, &acting_principal, &selector).await\n        },\n    }\n}\n\nasync fn mount(\n    client: &mut AdminClient,\n    acting_principal: PrincipalId,\n    view: astrid_core::storage_provider::StorageProviderViewV1,\n    access: StorageProviderAccessV1,\n    requested: Option<PathBuf>,\n) -> Result<StorageProviderSuccessV1> {\n    let (mountpoint, auto_created) = prepare_mountpoint(requested, &view)?;\n    let registry_key = path_key(&mountpoint)?;\n    if load_registry()?.mounts.contains_key(&registry_key) {\n        bail!(\"mountpoint is already registered: {}\", mountpoint.display());\n    }\n    let body = client\n        .request(AdminRequestKind::StorageMountIssue {\n            view,\n            access,\n            provider: PROVIDER_NAME.to_owned(),\n            mountpoint: mountpoint.clone(),\n        })\n        .await?;\n    let lease = lease_from_response(body)?;\n    let control_path = provider_control_path(&lease.mount_id)?;\n\n    if let Err(error) = native_mount(&lease, &mountpoint).await {\n        revoke_after_native_failure(client, &lease, auto_created, &mountpoint).await;\n        return Err(error);\n    }\n    let registered = update_registry(|registry| {\n        if registry.mounts.contains_key(&registry_key) {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/main.rs#L171-L207","documentation":"Before requesting a mount lease from the admin service, mount() computes the prepared mountpoint's registry key and checks the local mount registry. If a mount already occupies that mountpoint path, it bails rather than double-registering.","triggerScenarios":"Calling execute(StorageMount...) when load_registry()?.mounts already contains an entry for the key of the mountpoint produced by prepare_mountpoint() — i.e. a previous mount on the same path was never unmounted or removed from the registry.","commonSituations":"A previous provider run crashed after mounting without cleaning the registry; the same drive letter/path is requested twice; auto-created mountpoints collide with an existing registration; manual registry edits left stale entries.","solutions":["Unmount the existing mount on that path first (or remove the stale registry entry if the mount is already gone).","Request a different mountpoint path / drive letter via the `requested` argument.","Inspect the registry file for stale entries left by crashed runs and clean them up.","Ensure the previous unmount completed successfully before remounting the same path."],"exampleFix":"// before: remounting the same path fails\nclient_mount(\"Z:\", view, access)?;\n// after: release the existing mount first\nif registry_has_mount(\"Z:\") {\n    unmount(selector_for(\"Z:\", principal)).await?;\n}\nclient_mount(\"Z:\", view, access)?;","handlingStrategy":"validation","validationCode":"// Before requesting the mount:\nlet key = path_key(&PathBuf::from(\"Z:\"))?;\nif registry_file_contains(&key) {\n    // unmount first or choose another path\n}","typeGuard":null,"tryCatchPattern":"// Caller\nmatch mount(client, view, access, Some(path)).await {\n    Err(e) if e.to_string().starts_with(\"mountpoint is already registered\") => {\n        // unmount existing record or pick a different mountpoint\n    }\n    other => other?,\n}","preventionTips":["Always unmount cleanly; add shutdown hooks so crashes don't leave registry entries","Dynamically allocate drive letters/paths instead of hardcoding one","Audit the registry file for stale entries after crashes"],"tags":["winfsp","mount","registry-conflict","duplicate"],"backgroundTag":"address-already-in-use","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"}