{"record":{"id":"e6e624581e52d6a5","repo":"Hmbown/CodeWhale","slug":"runtime-store-path-must-be-a-directory","errorCode":null,"errorMessage":"Runtime store path must be a directory: {}","messagePattern":"Runtime store path must be a directory: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":13919,"sourceCode":"        .set_len(original_len)\n        .context(\"Failed to roll back Runtime event\")?;\n    rollback_file\n        .sync_all()\n        .context(\"Failed to sync Runtime event rollback\")\n}\n\nfn reject_symlinked_store_dir(path: &Path) -> Result<()> {\n    let Ok(metadata) = fs::symlink_metadata(path) else {\n        return Ok(());\n    };\n    if metadata.file_type().is_symlink() {\n        bail!(\n            \"Runtime store directory must not be a symlink: {}\",\n            path.display()\n        );\n    }\n    if !metadata.is_dir() {\n        bail!(\"Runtime store path must be a directory: {}\", path.display());\n    }\n    Ok(())\n}\n\nfn ensure_runtime_store_dir(path: &Path) -> Result<()> {\n    fs::create_dir_all(path).with_context(|| format!(\"Failed to create {}\", path.display()))?;\n    reject_symlinked_store_dir(path)\n}\n\nfn read_complete_event(\n    reader: &mut impl BufRead,\n    path: &Path,\n) -> Result<Option<RuntimeEventRecord>> {\n    Ok(read_complete_event_bytes(reader, path)?.map(|(event, _)| event))\n}\n\nfn read_complete_event_bytes(\n    reader: &mut impl BufRead,","sourceCodeStart":13901,"sourceCodeEnd":13937,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L13901-L13937","documentation":"After rejecting symlinks, reject_symlinked_store_dir also checks metadata.is_dir(); if the store path exists but is a regular file, socket, or other non-directory, opening the store would fail later, so it bails immediately with the path.","triggerScenarios":"The configured store path exists but is not a directory — commonly a regular file created by a misconfigured path (e.g. store root pointing at a file, or a file created where a dir was expected).","commonSituations":"Store root set to the path of a file (wrong config key); a previous single-file store layout; `touch`ed placeholder files; path collisions after migration.","solutions":["Remove the non-directory at that path and let the store create the directory (after backing up any data)","Correct the store-root config to point at a directory","Recover data from the file, then `mkdir` the expected directory"],"exampleFix":"// before\nstore_root = \"/home/u/.codewhale/runtime/store.jsonl\"  // a file\n// after\nmv /home/u/.codewhale/runtime/store.jsonl /home/u/.codewhale/runtime-backup.jsonl\nstore_root = \"/home/u/.codewhale/runtime\"","handlingStrategy":"validation","validationCode":"fn path_is_dir(p: &Path) -> bool {\n    std::fs::metadata(p).map(|m| m.is_dir()).unwrap_or(false)\n}","typeGuard":"fn existing_dir(p: &Path) -> Option<()> {\n    std::fs::metadata(p).ok()?.is_dir().then_some(())\n}","tryCatchPattern":"if !path_is_dir(&store_root) {\n    eprintln!(\"store root {} is not a directory; fix config\", store_root.display());\n    std::process::exit(2);\n}","preventionTips":["Verify the store-root config value points at a directory, not a file","Distinguish file-store vs dir-store config keys clearly","Back up and remove stray files before the store creates its directory"],"tags":["filesystem","path","validation"],"backgroundTag":"path-is-not-a-directory","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"}