{"record":{"id":"6c14e20e0ad975dd","repo":"zed-industries/zed","slug":"buffer-doesn-t-have-a-file","errorCode":null,"errorMessage":"buffer doesn't have a file","messagePattern":"buffer doesn't have a file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/project/src/buffer_store.rs","lineNumber":655,"sourceCode":"\n        for event in events {\n            cx.emit(event);\n        }\n\n        None\n    }\n\n    fn unloaded_ancestor_hides_path(snapshot: &worktree::Snapshot, path: &RelPath) -> bool {\n        path.ancestors()\n            .skip(1)\n            .find_map(|ancestor| snapshot.entry_for_path(ancestor))\n            .is_some_and(|entry| entry.kind == worktree::EntryKind::UnloadedDir)\n    }\n\n    fn save_buffer(\n        &self,\n        buffer: Entity<Buffer>,\n        cx: &mut Context<BufferStore>,\n    ) -> Task<Result<()>> {\n        let Some(file) = File::from_dyn(buffer.read(cx).file()) else {\n            return Task::ready(Err(anyhow!(\"buffer doesn't have a file\")));\n        };\n        let worktree = file.worktree.clone();\n        self.save_local_buffer(buffer, worktree, file.path.clone(), false, cx)\n    }\n\n    fn save_buffer_as(\n        &self,\n        buffer: Entity<Buffer>,\n        path: ProjectPath,\n        cx: &mut Context<BufferStore>,\n    ) -> Task<Result<()>> {\n        let Some(worktree) = self\n            .worktree_store\n            .read(cx)\n            .worktree_for_id(path.worktree_id, cx)","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/project/src/buffer_store.rs#L637-L673","documentation":"save_buffer was called on a buffer whose file is not a local File (unsaved/new buffer, or a remote-only file), so File::from_dyn returned None and there is no worktree path to save to. This is a guard against saving buffers that have no backing file.","triggerScenarios":"Thrown at crates/project/src/buffer_store.rs:655 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use save_buffer_as with an explicit target path for unsaved buffers","Trace callers to ensure they only attempt saves on file-backed buffers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}