{"record":{"id":"143fb9c7e6d638ec","repo":"Hmbown/CodeWhale","slug":"error-143fb9","errorCode":null,"errorMessage":"{error}","messagePattern":"\\{error\\}","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lsp/mod.rs","lineNumber":248,"sourceCode":"                        \"LSP file is outside the workspace\",\n                    )\n                })?;\n            // Match the existing workspace file serving ceiling. Decode only\n            // bounded UTF-8 bytes from the same no-follow workspace opener.\n            const MAX_DOCUMENT_BYTES: u64 = 16 * 1024 * 1024;\n            let file = crate::fleet::files::WorkspaceFile::open(&canonical_root, relative, false)?;\n            let mut bytes = Vec::new();\n            file.open_file()?\n                .take(MAX_DOCUMENT_BYTES + 1)\n                .read_to_end(&mut bytes)?;\n            if bytes.len() as u64 > MAX_DOCUMENT_BYTES {\n                return Err(std::io::Error::new(\n                    std::io::ErrorKind::InvalidData,\n                    \"LSP file exceeds the document limit\",\n                ));\n            }\n            String::from_utf8(bytes)\n                .map_err(|error| std::io::Error::new(std::io::ErrorKind::InvalidData, error))\n        })\n        .await\n        .map_err(std::io::Error::other)?\n    }\n\n    /// Inject a fake transport for a language. Used by tests so we never\n    /// fork a real LSP server in CI.\n    #[cfg(test)]\n    pub async fn install_test_transport(&self, lang: Language, transport: Arc<dyn LspTransport>) {\n        self.test_transports.lock().await.insert(lang, transport);\n    }\n\n    /// Poll the LSP server for diagnostics on `file`. Returns the rendered\n    /// [`DiagnosticBlock`] (already truncated to the configured per-file\n    /// max) or `None` when the manager is disabled / has no server / the\n    /// poll times out.\n    ///\n    /// The `_edit_seq` argument is currently a no-op; it exists in the","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lsp/mod.rs#L230-L266","documentation":"read_workspace_text converts any non-specific I/O failure from the bounded workspace read into io::Error::other, preserving the underlying error as its source. The message is the inner error's Display output. It wraps everything after the size-cap check, including the file open and UTF-8 conversion steps surfaced by the confined opener.","triggerScenarios":"read_workspace_text fails for a reason other than outside-workspace or size-cap: the no-follow open fails (file deleted mid-read, permission error, too many symlink levels, not-a-file), or from_utf8 fails producing an inner UTF-8 error.","commonSituations":"File removed or renamed between listing and reading; the entry is a directory or FIFO, not a regular file; a symlinked file inside the workspace rejected by the no-follow opener; a binary file passed where UTF-8 text is expected.","solutions":["Read the inner source error: re-check the path exists, is a regular file, and is readable before calling.","For non-UTF-8 files, convert or skip them — the reader only accepts valid UTF-8.","Retry if the failure was a transient race (file being rewritten); otherwise exclude the path from LSP requests."],"exampleFix":"// before\nread_workspace_text(&maybe_missing_path)?;\n// after\nif path.is_file() { read_workspace_text(&path)? } else { eprintln!(\"skipping {}\", path.display()) }","handlingStrategy":"try-catch","validationCode":"if !path.is_file() { eprintln!(\"not a regular file: {path:?}\"); }\nif std::fs::read(path).map(|b| std::str::from_utf8(&b).is_ok()).unwrap_or(false) { /* ok */ }","typeGuard":"fn readable_utf8_file(p: &Path) -> bool {\n    std::fs::read(p).map(|b| std::str::from_utf8(&b).is_ok()).unwrap_or(false)\n}","tryCatchPattern":"match read_workspace_text(p) {\n    Err(e) => { eprintln!(\"workspace read failed: {e} (source: {:?})\", e.source()); fallback_text() }\n    Ok(t) => use_text(t),\n}","preventionTips":["Verify existence and regular-file type before requesting text.","Expect races on files being rewritten; retry once or skip.","Ensure files are valid UTF-8; convert or skip binary files."],"tags":["lsp","io","filesystem"],"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-22T11:17:16.035Z"}