{"record":{"id":"d58b9a4cac88424c","repo":"sinelaw/fresh","slug":"no-file-path-associated-with-buffer","errorCode":null,"errorMessage":"No file path associated with buffer","messagePattern":"No file path associated with buffer","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor-core/src/model/buffer/mod.rs","lineNumber":730,"sourceCode":"            persistence: Persistence::new(\n                fs,\n                Some(path.to_path_buf()),\n                saved_root,\n                Some(file_size),\n            ),\n            file_kind: BufferFileKind::new(true, is_binary),\n            format: BufferFormat::new(line_ending, encoding),\n            version: 0,\n            config: BufferConfig::default(),\n        })\n    }\n\n    /// Save the buffer to its associated file\n    pub fn save(&mut self) -> anyhow::Result<()> {\n        if let Some(path) = self.persistence.file_path_owned() {\n            self.save_to_file(path)\n        } else {\n            anyhow::bail!(io::Error::new(\n                io::ErrorKind::NotFound,\n                \"No file path associated with buffer\",\n            ))\n        }\n    }\n\n    /// Build a write recipe from the piece tree for saving.\n    ///\n    /// Delegates to `save::build_write_recipe`.\n    #[cfg(test)]\n    pub(crate) fn build_write_recipe(&self) -> io::Result<WriteRecipe> {\n        save::build_write_recipe(\n            &self.piece_tree,\n            &self.buffers,\n            &self.format,\n            &self.file_kind,\n            &self.persistence,\n        )","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor-core/src/model/buffer/mod.rs#L712-L748","documentation":"Buffer::save persists the buffer to the file it is associated with. If the buffer has no file path (an untitled/scratch buffer, or one created from in-memory content), saving via save() is impossible, so it bails with an io::Error of kind NotFound carrying \"No file path associated with buffer\". The caller must instead use an explicit save-as flow with a chosen path.","triggerScenarios":"Calling buffer.save() on a buffer whose persistence.file_path_owned() returns None — i.e. a new untitled buffer, a scratch/clipboard buffer, or any buffer created without load_file/save_to_file ever having associated a path.","commonSituations":"User presses Ctrl+S in an untitled document without having done Save As; automation/tests constructing a Buffer directly and calling save(); buffers whose path association was cleared after a failed rename/move.","solutions":["Check buffer.persistence.file_path_owned() (or an equivalent has_path check) before calling save().","Route pathless buffers to a Save As flow: prompt for a path and call save_to_file(path) instead of save().","If the buffer should have a path, associate one first via the appropriate file-loading/attachment API."],"exampleFix":"// before\nbuffer.save()?; // panics/bails for untitled buffers\n\n// after\nmatch buffer.persistence.file_path_owned() {\n    Some(_) => buffer.save()?,\n    None => {\n        let path = prompt_save_as();\n        buffer.save_to_file(path)?;\n    }\n}","handlingStrategy":"validation","validationCode":"// Rust: verify the buffer has a path before saving\nlet can_save = buffer.persistence.file_path_owned().is_some();","typeGuard":null,"tryCatchPattern":"match buffer.save() {\n    Err(e) if e.to_string().contains(\"No file path associated with buffer\") => {\n        let path = prompt_save_as()?;\n        buffer.save_to_file(path)?;\n    }\n    other => other?,\n}","preventionTips":["Always call save() only after a path is associated (file opened or previously saved).","Bind Ctrl+S in UI to 'save-or-save-as' logic, not raw save().","In tests/automation, create buffers via file-loading APIs so a path exists."],"tags":["buffer","save","untitled","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}