{"record":{"id":"b32fe90608a2164e","repo":"Hmbown/CodeWhale","slug":"has-multiple-filesystem-links-not-a-unique-wor","errorCode":null,"errorMessage":"{} has multiple filesystem links, not a unique workspace-owned file","messagePattern":"(.+?) has multiple filesystem links, not a unique workspace-owned file","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2945,"sourceCode":"            continue;\n        }\n        if ch == '$' {\n            return true;\n        }\n    }\n    false\n}\n\nfn read_stable_workspace_dotenv(path: &Path) -> Result<Vec<u8>> {\n    let mut file = open_workspace_dotenv_without_following_links(path)?;\n    let metadata = file\n        .metadata()\n        .map_err(|error| anyhow!(\"could not inspect {}: {error}\", path.display()))?;\n    if !metadata.is_file() {\n        bail!(\"{} is not a regular file\", path.display());\n    }\n    if workspace_dotenv_has_multiple_links(&file, &metadata)? {\n        bail!(\n            \"{} has multiple filesystem links, not a unique workspace-owned file\",\n            path.display()\n        );\n    }\n    if metadata.len() > MAX_WORKSPACE_DOTENV_BYTES {\n        bail!(\n            \"{} exceeds the {} byte workspace .env limit\",\n            path.display(),\n            MAX_WORKSPACE_DOTENV_BYTES\n        );\n    }\n\n    let mut contents = Vec::with_capacity(metadata.len() as usize);\n    (&mut file)\n        .take(MAX_WORKSPACE_DOTENV_BYTES + 1)\n        .read_to_end(&mut contents)\n        .map_err(|error| anyhow!(\"could not read {}: {error}\", path.display()))?;\n    if contents.len() as u64 > MAX_WORKSPACE_DOTENV_BYTES {","sourceCodeStart":2927,"sourceCodeEnd":2963,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L2927-L2963","documentation":"After confirming the workspace .env is a regular file, read_stable_workspace_dotenv checks the hard-link count via workspace_dotenv_has_multiple_links; more than one link means the inode is shared, so the file is not uniquely owned by the workspace. Sharing an inode lets another path (possibly outside the workspace) alter the credential file after validation, so loading is refused.","triggerScenarios":"Workspace `.env` has st_nlink > 1: created via `ln .env other-name`, hard-linked from a dotfiles repo, or checked out from a filesystem (e.g. some git worktree/overlay setups) that hard-links unchanged files.","commonSituations":"Hard-linking .env into a secrets repo, backup tools that hard-link, or overlay/copy-on-write checkouts that preserve link counts.","solutions":["Replace the hard link with a copy: `rm .env && cp /path/to/source .env` (cp makes a fresh inode).","Find other links with `find / -samefile .env` and remove or unlink them.","Re-checkout or re-sync the file if your tooling (overlay fs, dotfile manager) hard-links unchanged files.","Store the .env only inside the workspace and reference it, rather than linking it in."],"exampleFix":"// before\nln ~/.secrets/codewhale.env .env\n// after\ncp ~/.secrets/codewhale.env .env   # copy, not hard link","handlingStrategy":"validation","validationCode":"// shell\nlinks=$(stat -c %h .env 2>/dev/null || stat -f %l .env); [ \"$links\" = \"1\" ] || { echo '.env has multiple hard links'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always copy (.env files in, never hard-link them.","Audit link counts with `find . -samefile .env` when dotfile/backup tools are in play.","Keep the credential file owned solely by the workspace."],"tags":["dotenv","filesystem","security","hardlink"],"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"}