{"record":{"id":"64179ecd541cb7f1","repo":"astrid-runtime/astrid","slug":"error","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-fuse/src/rollback.rs","lineNumber":33,"sourceCode":"}\n\npub(crate) fn finish_cleanup(\n    mut failures: Vec<String>,\n    detach: Result<()>,\n    cleanup: impl FnOnce() -> Result<()>,\n) -> Result<()> {\n    match detach {\n        Ok(()) => {\n            if let Err(error) = cleanup() {\n                failures.push(format!(\"remove service artifacts: {error:#}\"));\n            }\n        },\n        Err(error) => failures.push(format!(\"detach mountpoint: {error:#}\")),\n    }\n    if failures.is_empty() {\n        Ok(())\n    } else {\n        bail!(\"{}\", failures.join(\"; \"))\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use std::cell::Cell;\n\n    use super::*;\n\n    #[test]\n    fn failed_detach_retains_artifacts_and_preserves_every_failure() {\n        let cleanup_called = Cell::new(false);\n        let rollback = finish_cleanup(\n            vec![\n                \"control unmount: refused\".to_owned(),\n                \"revoke mount lease: denied\".to_owned(),\n            ],\n            Err(anyhow::anyhow!(\"busy\")),","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-fuse/src/rollback.rs#L15-L51","documentation":"finish_cleanup aggregates every failure that occurred while detaching the mountpoint and removing leftover artifacts; if any step failed it joins the messages with \"; \" and bails with that combined message. The error text is therefore the joined list of cleanup failures, not a single cause.","triggerScenarios":"Any cleanup step failing during rollback: umount2 error, failure removing the mountpoint directory, or other artifact-removal errors; multiple failures are concatenated.","commonSituations":"Mount still busy so MNT_DETACH errors; filesystem permission problems preventing artifact removal; NFS/network filesystems delaying unmount; multiple cascading failures after a failed launch.","solutions":["Read the joined messages to identify each failed sub-step and fix them individually","Retry the detach after resolving why the mount was busy (check lsof/fuser on the mountpoint)","Manually remove leftover artifacts (mountpoint directory) with correct permissions","Check for permission issues for the user running cleanup"],"exampleFix":"// before\n# cleanup fails: detach mountpoint: EBUSY; remove artifacts: permission denied\n// after\nfusermount -u -z /mnt/fuse && rm -rf /mnt/fuse  # then retry operation","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match finish_cleanup(steps) {\n    Err(e) => {\n        for failure in e.to_string().split(\"; \") {\n            eprintln!(\"cleanup step failed: {failure}\");\n        }\n    }\n    Ok(()) => {}\n}","preventionTips":["Parse the joined '; ' messages to address each failing step individually","Ensure the mount is idle (no open files) before triggering cleanup","Run cleanup as a user with permission to detach the mount and delete artifacts","Retry cleanup after resolving the first failure; later failures are often cascades"],"tags":["cleanup","rollback","mount"],"backgroundTag":"invalid-state-transition","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"}