{"record":{"id":"e91f8fea70efe355","repo":"biomejs/biome","slug":"this-file-wasn-t-open-with-write-access","errorCode":null,"errorMessage":"this file wasn't open with write access","messagePattern":"this file wasn't open with write access","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/biome_fs/src/fs/memory.rs","lineNumber":282,"sourceCode":"    fn read_to_string(&mut self, buffer: &mut String) -> io::Result<()> {\n        if !self.can_read {\n            return Err(io::Error::new(\n                io::ErrorKind::PermissionDenied,\n                \"this file wasn't open with read access\",\n            ));\n        }\n\n        // Verify the stored byte content is valid UTF-8\n        let content = str::from_utf8(&self.inner)\n            .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;\n        // Append the content of the file to the buffer\n        buffer.push_str(content);\n        Ok(())\n    }\n\n    fn set_content(&mut self, content: &[u8]) -> io::Result<()> {\n        if !self.can_write {\n            return Err(io::Error::new(\n                io::ErrorKind::PermissionDenied,\n                \"this file wasn't open with write access\",\n            ));\n        }\n\n        // Resize the memory buffer to fit the new content\n        self.inner.resize(content.len(), 0);\n        // Copy the new content into the memory buffer\n        self.inner.copy_from_slice(content);\n        // we increase its version\n        self.version += 1;\n        Ok(())\n    }\n\n    fn file_version(&self) -> i32 {\n        self.version\n    }\n}","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/biomejs/biome/blob/405dedb0ff65dd29927faf587f6542e3c29db248/crates/biome_fs/src/fs/memory.rs#L264-L300","documentation":"Error \"this file wasn't open with write access\" thrown in biomejs/biome.","triggerScenarios":"Thrown at crates/biome_fs/src/fs/memory.rs:282 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Open the file with write access (`OpenOptions::write(true)`) before calling `set_content` or writing."],"exampleFix":"let mut file = fs.open_with_options(path, OpenOptions::default().write(true))?; file.set_content(content)?;","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"405dedb0ff65dd29927faf587f6542e3c29db248","analyzedAt":"2026-08-20T00:25:09.682Z","contentChangedAt":"2026-08-20T00:25:09.682Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}