{"record":{"id":"5fa2823a5def88c0","repo":"Hmbown/CodeWhale","slug":"sub-agent-state-path-must-include-a-parent-directo","errorCode":null,"errorMessage":"sub-agent state path must include a parent directory","messagePattern":"sub-agent state path must include a parent directory","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":8654,"sourceCode":"        &Path::new(\".codewhale\")\n            .join(\"state\")\n            .join(SUBAGENT_STATE_FILE),\n    )\n}\n\nfn checked_subagent_state_path(state_root: &Path, path: &Path) -> Result<PathBuf> {\n    let state_root = normalize_subagent_workspace(state_root);\n    let absolute = if path.is_absolute() {\n        path.to_path_buf()\n    } else {\n        state_root.join(path)\n    };\n    let file_name = absolute\n        .file_name()\n        .ok_or_else(|| anyhow!(\"sub-agent state path must include a file name\"))?;\n    let parent = absolute\n        .parent()\n        .ok_or_else(|| anyhow!(\"sub-agent state path must include a parent directory\"))?;\n    // Resolve through the deepest existing ancestor so Windows short/long names\n    // and verbatim (`\\\\?\\`) spellings match the already-canonical state root.\n    // A missing parent used to fall back to lexical normalization and could keep\n    // an 8.3 component (for example `RUNNER~1`) that no longer prefixes the root.\n    let parent = resolve_path_for_containment(parent)?;\n    let state_path = parent.join(file_name);\n    if !path_is_within_state_root(&state_path, &state_root) {\n        return Err(anyhow!(\n            \"sub-agent state path must stay within state root: {}\",\n            state_path.display()\n        ));\n    }\n    reject_root_relative_symlinks(&state_root, &state_path)?;\n    Ok(state_path)\n}\n\n/// Canonicalize `path` when it exists; otherwise canonicalize the deepest\n/// existing ancestor and re-append the missing tail. Keeps containment checks","sourceCodeStart":8636,"sourceCodeEnd":8672,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L8636-L8672","documentation":"After requiring a file-name component, the resolver calls `Path::parent()` to obtain the directory that will be canonicalized for containment checking. A path with no parent (e.g. a bare relative file name or a filesystem root) cannot be processed, so this error is thrown. It is a sibling guard to the file-name check and rarely fires alone.","triggerScenarios":"Calling a sub-agent state API with a path that has no parent component — e.g. `Path::new(\"session.json\")` after resolution, or a root path like `/`.","commonSituations":"Passing just a file name relative to the process CWD expecting the library to resolve it against the state root; passing `/` or a drive root directly; misconfigured state path that collapses to a root.","solutions":["Provide a fully qualified path including its directory, e.g. `<state_root>/session.json`.","Join the file name onto the state root yourself before calling the API.","Verify config values so the state path never resolves to a bare file name or root.","Ensure the path is absolute (or rooted under the configured state root) before calling."],"exampleFix":"// before\nresolve_state_path(state_root, Path::new(\"session.json\"))\n// after\nresolve_state_path(state_root, &state_root.join(\"session.json\"))","handlingStrategy":"validation","validationCode":"fn state_path_has_parent(p: &std::path::Path) -> bool {\n    p.parent().is_some() && p.file_name().is_some()\n}\n// guard: state_path_has_parent(&path)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Join bare file names onto the state root before calling the API.","Never pass `/` or a drive root as a state path.","Validate that configured state paths are absolute with a directory component."],"tags":["subagent","path","validation"],"backgroundTag":"invalid-argument-value","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"}