{"record":{"id":"57279e1edc060388","repo":"Hmbown/CodeWhale","slug":"path-has-no-parent-directory","errorCode":null,"errorMessage":"path has no parent directory: {}","messagePattern":"path has no parent directory: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/utils.rs","lineNumber":288,"sourceCode":"///   (same candidate mode as ordinary `std::fs::write`).\n/// - Existing files keep ordinary permission bits (`mode & 0o777`), including\n///   executable bits. setuid/setgid/sticky are intentionally not restored.\n///\n/// On Windows this matches [`write_atomic`] (no POSIX mode simulation).\n///\n/// # Errors\n/// Same failure modes as [`write_atomic`].\npub fn write_atomic_workspace(path: &Path, contents: &[u8]) -> std::io::Result<()> {\n    write_atomic_with_permissions(path, contents, AtomicWritePermissions::Workspace)\n}\n\nfn write_atomic_with_permissions(\n    path: &Path,\n    contents: &[u8],\n    #[cfg_attr(not(unix), allow(unused_variables))] permission_policy: AtomicWritePermissions,\n) -> std::io::Result<()> {\n    let parent = path.parent().ok_or_else(|| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            format!(\"path has no parent directory: {}\", path.display()),\n        )\n    })?;\n\n    // Capture ordinary rwx bits before replacement. Use symlink_metadata so we\n    // do not follow links: an inaccessible or dangling symlink target must not\n    // abort the write — rename still replaces the directory entry, matching\n    // the pre-#4606 private write_atomic behavior. Symlink entries themselves\n    // are treated as \"no mode to preserve\" (new ordinary file after rename);\n    // only regular-file modes are restored. Mask with 0o777 so setuid/setgid/\n    // sticky are never restored after rewriting content.\n    #[cfg(unix)]\n    let existing_workspace_mode = if permission_policy == AtomicWritePermissions::Workspace {\n        match fs::symlink_metadata(path) {\n            Ok(metadata) if metadata.file_type().is_symlink() => None,\n            Ok(metadata) => {\n                use std::os::unix::fs::PermissionsExt;","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/utils.rs#L270-L306","documentation":"write_atomic_with_permissions() needs the parent directory of the target path to stage its temp file, but path.parent() returned None because the path is a bare file name or root with no directory component. A generic precondition guard on caller-supplied paths, raised from write_atomic_workspace.","triggerScenarios":"Thrown at crates/tui/src/utils.rs:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an absolute path with a real parent directory","Join the file name onto an explicit workspace/base directory before writing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}