{"record":{"id":"c56e5c6ba7fbbc78","repo":"Hmbown/CodeWhale","slug":"could-not-read-error","errorCode":null,"errorMessage":"could not read {}: {error}","messagePattern":"could not read (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2962,"sourceCode":"    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 {\n        bail!(\n            \"{} exceeds the {} byte workspace .env limit\",\n            path.display(),\n            MAX_WORKSPACE_DOTENV_BYTES\n        );\n    }\n    Ok(contents)\n}\n\n#[cfg(unix)]\nfn workspace_dotenv_has_multiple_links(\n    _file: &std::fs::File,\n    metadata: &std::fs::Metadata,\n) -> Result<bool> {\n    use std::os::unix::fs::MetadataExt;\n\n    Ok(metadata.nlink() > 1)","sourceCodeStart":2944,"sourceCodeEnd":2980,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L2944-L2980","documentation":"The `.env` contents are read with a `take(MAX_WORKSPACE_DOTENV_BYTES + 1)` limit. Any read error surfaces as this error with the path and underlying io::Error; the subsequent length check produces the separate size-limit error.","triggerScenarios":"`read_to_end` on the opened `.env` fails (I/O error mid-read), independent of the size check that follows.","commonSituations":"Disk errors, interrupted reads on network mounts, or a file changing size between open and read.","solutions":["Inspect the `{error}` suffix for the io::ErrorKind and address that filesystem issue.","Copy the `.env` to local storage if it lives on an unreliable mount.","Retry the startup; if persistent, check disk health and permissions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let max: u64 = 64 * 1024; // match MAX_WORKSPACE_DOTENV_BYTES\nif std::fs::metadata(\".env\")?.len() > max { eprintln!(\".env exceeds workspace size limit\"); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = read_stable_workspace_dotenv(&path) {\n    if e.to_string().contains(\"could not read\") {\n        eprintln!(\"resolve the io error in the message, then retry: {e:#}\");\n    }\n}","preventionTips":["Check `.env` size against the workspace byte limit before startup.","Keep `.env` minimal — only credential keys the loader recognizes.","Don't place large blob files named `.env` in the workspace."],"tags":["filesystem","io","dotenv"],"backgroundTag":"file-read-failed","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"}