{"record":{"id":"951e4ecd5ec7c152","repo":"Hmbown/CodeWhale","slug":"snapshot-dir-has-no-parent","errorCode":null,"errorMessage":"snapshot dir has no parent","messagePattern":"snapshot dir has no parent","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/snapshot/repo.rs","lineNumber":354,"sourceCode":"        let needs_init = !git_dir.exists();\n        if needs_init {\n            // First-init size guard. Skipping this on subsequent opens\n            // is intentional: paying a workspace walk on every snapshot\n            // would defeat the purpose of the cap, and a workspace\n            // that fit on first init is allowed to grow within the\n            // existing repo's `MAX_SNAPSHOT_SIZE_MB` budget. Users on\n            // workspaces that grew past the cap mid-session get the\n            // existing aggressive-pruning path in `snapshot()`.\n            if let Err(gate) =\n                estimate_workspace_size_bounded(&work_tree, cap_bytes, SIZE_WALK_MAX_ENTRIES)\n            {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    gate.describe(cap_bytes, workspace),\n                ));\n            }\n            let parent = git_dir.parent().ok_or_else(|| {\n                io::Error::new(io::ErrorKind::InvalidInput, \"snapshot dir has no parent\")\n            })?;\n            std::fs::create_dir_all(parent)?;\n            // `git init` here uses the parent directory as the work tree\n            // and stores metadata in `.git`. We then continue to use\n            // explicit `--git-dir` / `--work-tree` flags for every other\n            // command so behaviour is invariant of cwd.\n            let init = crate::dependencies::Git::command()\n                .ok_or_else(|| io_other(\"git not found on PATH\"))?\n                .arg(\"init\")\n                .arg(\"--quiet\")\n                .arg(parent)\n                .output()\n                .map_err(|e| io_other(format!(\"failed to spawn git init: {e}\")))?;\n            if !init.status.success() {\n                return Err(io_other(format!(\n                    \"git init failed: {}\",\n                    String::from_utf8_lossy(&init.stderr).trim()\n                )));","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/snapshot/repo.rs#L336-L372","documentation":"In open_or_init_with_cap, after computing the snapshot repo's git_dir, the code takes `git_dir.parent()` to use as the work-tree parent for `git init`. If the snapshot dir has no parent (i.e. it is a filesystem root like `/` or `C:\\`), this InvalidInput error fires. It signals an internal configuration problem: the snapshot storage path was resolved to a root directory.","triggerScenarios":"Snapshot storage directory configured or resolved to a filesystem root, so git_dir.parent() returns None during repo init.","commonSituations":"A config value or path construction that collapses the snapshot dir to \"/\" or a drive root; pathological state-dir resolution on unusual mounts.","solutions":["Check the snapshot/state directory configuration — it must nest at least one level below a root.","Inspect how the snapshot dir path was constructed (state dir resolution) and fix the input that produced a root path.","Report as a bug if the default configuration produced a root path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn snapshot_dir_ok(p: &Path) -> bool {\n    p.parent().is_some() && p != Path::new(\"/\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never configure the snapshot/state directory as a filesystem root.","Verify resolved snapshot paths have at least one parent component.","Report to maintainers if default config produces a root path."],"tags":["internal","path-resolution","snapshots"],"backgroundTag":"internal-invariant-violation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}