{"record":{"id":"b075f3a749f64545","repo":"Hmbown/CodeWhale","slug":"runtime-store-directory-must-not-be-a-symlink","errorCode":null,"errorMessage":"Runtime store directory must not be a symlink: {}","messagePattern":"Runtime store directory must not be a symlink: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":13913,"sourceCode":"    std::thread::sleep(EVENT_TRANSACTION_LOCK_POLL.min(timeout - elapsed));\n    Ok(())\n}\n\nfn rollback_failed_event_append_handle(rollback_file: &File, original_len: u64) -> Result<()> {\n    rollback_file\n        .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,","sourceCodeStart":13895,"sourceCodeEnd":13931,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L13895-L13931","documentation":"reject_symlinked_store_dir verifies the store directory itself is a real directory, not a symlink, to keep the store anchored at the intended location. Symlinks are rejected; non-directory paths get a separate error.","triggerScenarios":"The configured store directory path exists and symlink_metadata reports it is a symlink (e.g. the store root itself is a link to another location).","commonSituations":"Symlinking ~/.local/share/codewhale to another volume; XDG dirs replaced by links; container images pre-linking data directories.","solutions":["Bind-mount or configure the real directory path directly instead of symlinking","Replace the symlink with a real directory and move the data","Set the store root config to the symlink's target path"],"exampleFix":"// before\n$ ln -s /mnt/data/runtime ~/.codewhale/runtime\n// after\n# in config: store_root = \"/mnt/data/runtime\"\n$ rm ~/.codewhale/runtime","handlingStrategy":"validation","validationCode":"fn dir_is_real(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| m.is_dir() && !m.file_type().is_symlink()).unwrap_or(false)\n}","typeGuard":"fn real_dir(p: &Path) -> Option<()> {\n    let m = std::fs::symlink_metadata(p).ok()?;\n    (m.is_dir() && !m.file_type().is_symlink()).then_some(())\n}","tryCatchPattern":"if !dir_is_real(&store_dir) {\n    let target = store_dir.read_link().unwrap_or(store_dir.to_path_buf());\n    store.open(target).await?;\n}","preventionTips":["Point config at the symlink target rather than the link","Avoid dotfile managers managing runtime data dirs","Check symlink_metadata on store dirs at startup"],"tags":["security","symlink","filesystem"],"backgroundTag":"permission-denied","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"}