{"record":{"id":"821ebf7908179d06","repo":"astrid-runtime/astrid","slug":"winfsp-service-mountpoint-is-not-empty","errorCode":null,"errorMessage":"WinFsp service mountpoint is not empty","messagePattern":"WinFsp service mountpoint is not empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/win.rs","lineNumber":311,"sourceCode":"            .components()\n            .any(|component| matches!(component, std::path::Component::ParentDir))\n    {\n        bail!(\"WinFsp service mountpoint is malformed\");\n    }\n    if is_public_mountpoint(&launch.mountpoint)\n        || launch.mountpoint.parent().is_none()\n        || launch.mountpoint == lease.resource_path\n        || launch.mountpoint.starts_with(&lease.resource_path)\n        || lease.resource_path.starts_with(&launch.mountpoint)\n    {\n        bail!(\"WinFsp service mountpoint is public or overlaps the lease resource\");\n    }\n    platform_fs::validate_private_directory(&launch.mountpoint)\n        .context(\"validate private WinFsp mountpoint\")?;\n    platform_fs::verify_no_redirects(&launch.mountpoint)\n        .context(\"reject redirected WinFsp mountpoint\")?;\n    if std::fs::read_dir(&launch.mountpoint)?.next().is_some() {\n        bail!(\"WinFsp service mountpoint is not empty\");\n    }\n    if !launch.control_path.is_absolute()\n        || launch\n            .control_path\n            .components()\n            .any(|component| matches!(component, std::path::Component::ParentDir))\n        || launch.control_path != lease.resource_path.join(\"process-control.sock\")\n    {\n        bail!(\"WinFsp service control path is malformed\");\n    }\n    let control_parent = launch\n        .control_path\n        .parent()\n        .context(\"WinFsp service control path has no parent\")?;\n    platform_fs::validate_private_directory(control_parent)\n        .context(\"validate private WinFsp control parent\")?;\n    platform_fs::verify_no_redirects(&launch.control_path)\n        .context(\"reject redirected WinFsp control path\")?;","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/win.rs#L293-L329","documentation":"Before mounting, the target mountpoint directory must be completely empty — WinFsp will present the virtual filesystem's contents there, and pre-existing files would be shadowed or mixed with the mount. If std::fs::read_dir finds any entry in the directory, validate_service_launch bails rather than silently hiding or clobbering existing data.","triggerScenarios":"service_main -> validate_service_launch where std::fs::read_dir(&launch.mountpoint)?.next().is_some(): any file, subdirectory, or even a leftover control endpoint exists inside the mountpoint directory at launch time.","commonSituations":"Remounting after an unclean shutdown that left stale files in the mountpoint; a previous mount's contents were materialized to disk; users pre-created files in the folder they designated as the mountpoint; a prior failed launch left a partially-copied state.","solutions":["Empty the mountpoint directory before launching (move its contents aside or delete them after user confirmation).","Use a fresh, dedicated per-mount directory (e.g. named by mount_id) instead of a shared folder, so it is empty by construction.","Check the mountpoint for leftover content in your launcher and fail early with a user-facing message rather than reaching the service.","If the previous mount crashed, clean up its mountpoint during recovery before issuing a new launch descriptor."],"exampleFix":"// before\nspawn_service(launch); // mountpoint may contain leftovers\n// after\nfor entry in fs::read_dir(&mountpoint)? { /* stash or delete entries */ }\nspawn_service(launch);","handlingStrategy":"validation","validationCode":"if std::fs::read_dir(&mountpoint)?.next().is_some() {\n    return Err(anyhow!(\"mountpoint {} must be empty before mounting\", mountpoint.display()));\n}","typeGuard":null,"tryCatchPattern":"match start_mount(&launch) {\n    Err(e) if e.to_string().contains(\"mountpoint is not empty\") => {\n        archive_mountpoint_contents(&launch.mountpoint)?;\n        start_mount(&launch)\n    }\n    other => other,\n}","preventionTips":["Provision a fresh empty directory per mount instead of reusing folders","Clean the mountpoint after unclean shutdowns before remounting","Ask users to designate an empty folder; check it in your launcher before spawning the service","During recovery, move leftover mountpoint contents to a backup path rather than deleting blindly"],"tags":["winfsp","mountpoint","filesystem","validation"],"backgroundTag":"directory-not-found","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"}