{"record":{"id":"1bafaea009876f44","repo":"zed-industries/zed","slug":"failed-to-apply-uncommitted-diff-patch-with-status","errorCode":null,"errorMessage":"Failed to apply uncommitted diff patch with status: {}\nstderr:\n{}\nstdout:\n{}","messagePattern":"Failed to apply uncommitted diff patch with status: (.+?)\nstderr:\n(.+?)\nstdout:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/load_project.rs","lineNumber":374,"sourceCode":"        step_progress.set_substatus(\"applying diff\");\n\n        // old examples had full paths in the uncommitted diff.\n        let uncommitted_diff =\n            strip_diff_path_prefix(&example.spec.uncommitted_diff, &repo_name.name);\n\n        let mut apply_process = smol::process::Command::new(\"git\")\n            .current_dir(&worktree_path)\n            .args(&[\"apply\", \"-\"])\n            .stdin(std::process::Stdio::piped())\n            .spawn()?;\n\n        let mut stdin = apply_process.stdin.take().context(\"Failed to get stdin\")?;\n        stdin.write_all(uncommitted_diff.as_bytes()).await?;\n        stdin.close().await?;\n        drop(stdin);\n\n        let apply_result = apply_process.output().await?;\n        anyhow::ensure!(\n            apply_result.status.success(),\n            \"Failed to apply uncommitted diff patch with status: {}\\nstderr:\\n{}\\nstdout:\\n{}\",\n            apply_result.status,\n            String::from_utf8_lossy(&apply_result.stderr),\n            String::from_utf8_lossy(&apply_result.stdout),\n        );\n    }\n\n    step_progress.clear_substatus();\n    Ok(worktree_path)\n}\n\nasync fn apply_edit_history(\n    example: &Example,\n    project: &Entity<Project>,\n    cx: &mut AsyncApp,\n) -> Result<OpenedBuffers> {\n    edit_prediction::udiff::apply_diff(&example.spec.edit_history, project, cx).await","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/load_project.rs#L356-L392","documentation":"setup_worktree pipes the example's uncommitted diff into `git apply -` and the apply process exited with the reported status; the embedded stderr shows why the patch did not fit the checked-out worktree (conflict, corrupt diff, or path prefix mismatch).","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/load_project.rs:374 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the embedded stderr for git apply's conflict details","Regenerate the example/diff against the matching commit","Ensure the worktree is at the expected base commit before applying"],"exampleFix":null,"handlingStrategy":"try-catch","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-14T05:17:10.506Z"}