{"record":{"id":"73c7614950533d43","repo":"zed-industries/zed","slug":"wrong-file-type","errorCode":null,"errorMessage":"Wrong file type","messagePattern":"Wrong file type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction/src/udiff.rs","lineNumber":241,"sourceCode":"                    anyhow::Ok(())\n                })?;\n            }\n            DiffEvent::FileEnd { renamed_to } => {\n                let buffer = current_file\n                    .take()\n                    .context(\"Got a FileEnd event before an Hunk event\")?;\n\n                if let Some(renamed_to) = renamed_to {\n                    project\n                        .update(cx, |project, cx| {\n                            let new_project_path = project\n                                .find_project_path(Path::new(renamed_to.as_ref()), cx)\n                                .with_context(|| {\n                                    format!(\"Failed to find worktree for new path: {}\", renamed_to)\n                                })?;\n\n                            let project_file = project::File::from_dyn(buffer.read(cx).file())\n                                .expect(\"Wrong file type\");\n\n                            anyhow::Ok(project.rename_entry(\n                                project_file.entry_id.unwrap(),\n                                new_project_path,\n                                cx,\n                            ))\n                        })?\n                        .await?;\n                }\n\n                let edits = mem::take(&mut edits);\n                buffer.update(cx, |buffer, cx| {\n                    buffer.edit(edits, None, cx);\n                });\n            }\n        }\n    }\n","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction/src/udiff.rs#L223-L259","documentation":"Guard in edit_prediction's apply_diff when processing a unidiff event stream: a FileEnd event arrives (optionally carrying a rename target) before any Hunk event opened a current file, meaning the diff stream is malformed or the parser skipped the file header.","triggerScenarios":"Thrown at crates/edit_prediction/src/udiff.rs:241 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the unified diff being applied is well-formed and starts with file headers","Verify the diff producer (model output or tool) isn't emitting truncated diffs","Re-generate or re-fetch the diff and retry the application"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}