{"record":{"id":"3b5d57628cfdc928","repo":"Hmbown/CodeWhale","slug":"runtime-store-file-must-not-be-a-symlink","errorCode":null,"errorMessage":"Runtime store file must not be a symlink: {}","messagePattern":"Runtime store file must not be a symlink: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":13748,"sourceCode":"            Component::ParentDir => {\n                normalized.pop();\n            }\n            Component::Normal(part) => normalized.push(part),\n        }\n    }\n    if normalized.as_os_str().is_empty() {\n        PathBuf::from(\".\")\n    } else {\n        normalized\n    }\n}\n\nfn reject_symlinked_store_file(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 file must not be a symlink: {}\",\n            path.display()\n        );\n    }\n    Ok(())\n}\n\nfn open_runtime_store_file(\n    path: &Path,\n    purpose: &str,\n    configure: impl FnOnce(&mut OpenOptions),\n) -> Result<File> {\n    reject_symlinked_store_file(path)?;\n    let mut options = OpenOptions::new();\n    configure(&mut options);\n    #[cfg(unix)]\n    {\n        use std::os::unix::fs::OpenOptionsExt as _;","sourceCodeStart":13730,"sourceCodeEnd":13766,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L13730-L13766","documentation":"Before using an existing runtime store file, reject_symlinked_store_file checks its symlink_metadata; a symlink would let the store read/write outside the intended location, so it is rejected. Missing files pass (the store creates them).","triggerScenarios":"The store file path already exists and is a symlink when the runtime store opens or writes that file.","commonSituations":"Users symlinking store files to another disk/home to save space; backup-restore tooling replacing files with symlinks; dotfile managers linking config/store files.","solutions":["Replace the symlink with a real file (copy the target content to the path)","Point the store root at the real directory instead of symlinking individual files","Verify with `ls -l` / symlink_metadata that no store file is a link before starting"],"exampleFix":"// before\n$ ln -s /mnt/big/store.jsonl ~/.codewhale/runtime/store.jsonl\n// after\n$ rm ~/.codewhale/runtime/store.jsonl && cp /mnt/big/store.jsonl ~/.codewhale/runtime/store.jsonl","handlingStrategy":"validation","validationCode":"fn is_symlink(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| m.file_type().is_symlink()).unwrap_or(false)\n}","typeGuard":"fn real_file(p: &Path) -> Option<()> {\n    let m = std::fs::symlink_metadata(p).ok()?;\n    (!m.file_type().is_symlink()).then_some(())\n}","tryCatchPattern":"if is_symlink(&store_file) {\n    std::fs::copy(store_file.read_link()?, &store_file)?; // materialize\n}","preventionTips":["Configure the real directory instead of symlinking store files","Check for symlinks after restores or dotfile-manager runs","Document that store paths must be real files"],"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"}