{"record":{"id":"c047d71acba59baa","repo":"openai/codex","slug":"i-o-error-while-reading-memories-0","errorCode":null,"errorMessage":"I/O error while reading memories: {0}","messagePattern":"I/O error while reading memories: (.+?)","errorType":"exception","errorClass":"MemoriesBackendError","httpStatus":null,"severity":"error","filePath":"codex-rs/ext/memories/src/backend.rs","lineNumber":161,"sourceCode":"    #[error(\"path '{path}' {reason}\")]\n    InvalidPath { path: String, reason: String },\n    #[error(\"cursor '{cursor}' {reason}\")]\n    InvalidCursor { cursor: String, reason: String },\n    #[error(\"path '{path}' was not found\")]\n    NotFound { path: String },\n    #[error(\"line_offset must be a 1-indexed line number\")]\n    InvalidLineOffset,\n    #[error(\"max_lines must be a positive integer\")]\n    InvalidMaxLines,\n    #[error(\"line_offset exceeds file length\")]\n    LineOffsetExceedsFileLength,\n    #[error(\"path '{path}' is not a file\")]\n    NotFile { path: String },\n    #[error(\"queries must not be empty or contain empty strings\")]\n    EmptyQuery,\n    #[error(\"all_within_lines.line_count must be a positive integer\")]\n    InvalidMatchWindow,\n    #[error(\"I/O error while reading memories: {0}\")]\n    Io(#[from] std::io::Error),\n}\n\nimpl MemoriesBackendError {\n    pub fn invalid_filename(filename: impl Into<String>, reason: impl Into<String>) -> Self {\n        Self::InvalidFilename {\n            filename: filename.into(),\n            reason: reason.into(),\n        }\n    }\n\n    pub fn invalid_path(path: impl Into<String>, reason: impl Into<String>) -> Self {\n        Self::InvalidPath {\n            path: path.into(),\n            reason: reason.into(),\n        }\n    }\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/ext/memories/src/backend.rs#L143-L179","documentation":"The catch-all I/O variant of MemoriesBackendError, auto-converted from std::io::Error with #[from] (codex-rs/ext/memories/src/backend.rs:161-162). It surfaces whenever an underlying filesystem operation in the local backend fails: reading a memory file (tokio::fs::read_to_string in local/read.rs:34), stat calls via metadata_or_none, or directory iteration while listing and searching. The embedded io::Error's kind and message carry the real cause, such as PermissionDenied, NotFound from a race, or InvalidData because a file in the store is not valid UTF-8.","triggerScenarios":"A memory file that is not valid UTF-8 (read_to_string fails with InvalidData); permission-denied entries under the memory root during read/list/search; a path that vanishes between the metadata check and the read; disk or lower-level I/O failures.","commonSituations":"Binary or non-UTF-8 files dropped into the memory directory; restrictive ownership after running under different accounts; cloud-sync tools churning the directory; full disks.","solutions":["Inspect the embedded std::io::Error (kind and message); it names the failing path and cause.","For InvalidData (non-UTF-8), remove, rename, or re-save the offending file as UTF-8; the backend cannot read arbitrary bytes.","For PermissionDenied, fix ownership and permissions on the memory root and its entries.","For NotFound races or transient errors, re-list and retry once."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Rust - optional pre-flight for the common UTF-8/permission causes\nasync fn memory_readable(path: &std::path::Path) -> bool {\n    match tokio::fs::read(path).await {\n        Ok(bytes) => std::str::from_utf8(&bytes).is_ok(),\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match backend.read(request).await {\n    Ok(resp) => { /* ... */ }\n    Err(MemoriesBackendError::Io(e)) => match e.kind() {\n        std::io::ErrorKind::PermissionDenied => { /* fix perms on the memory root */ }\n        std::io::ErrorKind::InvalidData => { /* non-UTF-8 memory file: rename or remove it */ }\n        std::io::ErrorKind::NotFound => { /* vanished mid-scan: re-list, retry once */ }\n        _ => return Err(MemoriesBackendError::Io(e)),\n    },\n    Err(e) => return Err(e),\n}","preventionTips":["Keep only UTF-8 text files in the memory store.","Check ownership and permissions on the memory root after account or container changes.","Always log the embedded io::Error; it identifies the failing file.","Retry once on NotFound races; never blind-retry PermissionDenied."],"tags":["rust","codex","memories","filesystem","io","utf-8","permissions"],"backgroundTag":"filesystem-io-error","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}