{"record":{"id":"56c525d8b63d126b","repo":"astrid-runtime/astrid","slug":"mountpoint-is-not-empty","errorCode":null,"errorMessage":"mountpoint is not empty: {}","messagePattern":"mountpoint is not empty: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-fskit/src/main.rs","lineNumber":480,"sourceCode":"    let leaf = match view {\n        astrid_core::storage_provider::StorageProviderViewV1::Principal(principal) => {\n            principal.to_string()\n        },\n        astrid_core::storage_provider::StorageProviderViewV1::Fleet(fleet) => fleet.to_string(),\n        astrid_core::storage_provider::StorageProviderViewV1::Admin => \"system\".to_owned(),\n    };\n    Ok(home.join(\"Astrid\").join(leaf))\n}\n\nfn validate_unmounted_mountpoint(mountpoint: &Path) -> Result<()> {\n    validate_mountpoint_layout(mountpoint)?;\n    validate_mountpoint_ancestors(mountpoint)?;\n    astrid_core::platform_fs::verify_no_redirects(mountpoint)\n        .with_context(|| format!(\"reject redirected mountpoint {}\", mountpoint.display()))?;\n    astrid_core::platform_fs::validate_private_directory(mountpoint)\n        .with_context(|| format!(\"reject unsafe mountpoint {}\", mountpoint.display()))?;\n    if std::fs::read_dir(mountpoint)?.next().is_some() {\n        bail!(\"mountpoint is not empty: {}\", mountpoint.display());\n    }\n    Ok(())\n}\n\nfn validate_mounted_mountpoint(mountpoint: &Path) -> Result<()> {\n    validate_mountpoint_layout(mountpoint)?;\n    validate_mountpoint_ancestors(mountpoint)?;\n    astrid_core::platform_fs::verify_no_redirects(mountpoint)\n        .with_context(|| format!(\"reject redirected mountpoint {}\", mountpoint.display()))?;\n    if !native_mount_is_active(mountpoint)? {\n        bail!(\n            \"macOS did not activate an astridfs mount at {}\",\n            mountpoint.display()\n        );\n    }\n    Ok(())\n}\n","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-fskit/src/main.rs#L462-L498","documentation":"validate_unmounted_mountpoint() performs full safety validation (layout, ancestors, no symlink redirects, private-directory permissions) and finally requires the directory to be empty; if read_dir yields any entry, the path is either still mounted, mid-teardown, or contains foreign files, so the provider refuses to proceed rather than clobber data.","triggerScenarios":"Called from unmount (after native unmount), cleanup_created_mountpoint, prepare_mountpoint (before mount on an existing dir), and tests; fires when any file, directory, or dotfile exists in the mountpoint — commonly because the native unmount did not actually take effect or something repopulated the directory.","commonSituations":"Leftover .DS_Store or fseventsd files on macOS after unmount; user data saved into the folder while mounted; a second mount/daemon still holding the path; hidden files from a previous failed run.","solutions":["Confirm nothing is mounted there (mount | grep the path; native_mount_is_active) and unmount if needed.","List the directory (ls -la) and remove or move out leftover files, then retry the operation.","If .DS_Store/fseventsd-style debris keeps appearing on macOS, clean it after each unmount or use a dedicated mountpoint.","Ensure only one provider instance manages this mountpoint to avoid concurrent repopulation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn assert_empty_unmounted(path: &Path) -> anyhow::Result<()> {\n    if std::fs::read_dir(path)?.next().is_some() {\n        anyhow::bail!(\"{} not empty\", path.display());\n    }\n    Ok(())\n}\n// run before mount requests targeting an existing directory","typeGuard":null,"tryCatchPattern":"if let Err(e) = validate_unmounted_mountpoint(&mountpoint) {\n    if e.to_string().contains(\"mountpoint is not empty\") {\n        // check for active mount, clean debris (.DS_Store, fseventsd), then retry\n    }\n}","preventionTips":["Confirm the native mount is gone before treating the directory as reusable.","Handle macOS metadata files (.DS_Store, .fseventsd) that linger after unmount.","Run a single provider instance per mountpoint to prevent concurrent writes.","Inspect with ls -la for hidden leftovers when this error fires."],"tags":["mountpoint","empty-directory","safety-check","macos"],"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-14T11:17:12.474Z"}