{"record":{"id":"9f6b3e2c64fa64f9","repo":"zed-industries/zed","slug":"stash-has-changed-not-applying","errorCode":null,"errorMessage":"Stash has changed, not applying","messagePattern":"Stash has changed, not applying","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git_ui/src/commit_view.rs","lineNumber":780,"sourceCode":"                                        .track_scroll(&self.message_scroll_handle)\n                                })\n                                .child(MarkdownElement::new(self.message.clone(), markdown_style)),\n                        )\n                        .vertical_scrollbar_for(&self.message_scroll_handle, window, cx),\n                ),\n        )\n    }\n\n    fn apply_stash(workspace: &mut Workspace, window: &mut Window, cx: &mut App) {\n        Self::stash_action(\n            workspace,\n            \"Apply\",\n            window,\n            cx,\n            async move |repository, sha, stash, commit_view, workspace, cx| {\n                let result = repository.update(cx, |repo, cx| {\n                    if !stash_matches_index(&sha, stash, repo) {\n                        return Err(anyhow::anyhow!(\"Stash has changed, not applying\"));\n                    }\n                    Ok(repo.stash_apply(Some(stash), cx))\n                });\n\n                match result {\n                    Ok(task) => task.await?,\n                    Err(err) => {\n                        Self::close_commit_view(commit_view, workspace, cx).await?;\n                        return Err(err);\n                    }\n                };\n                Self::close_commit_view(commit_view, workspace, cx).await?;\n                anyhow::Ok(())\n            },\n        );\n    }\n\n    fn pop_stash(workspace: &mut Workspace, window: &mut Window, cx: &mut App) {","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/git_ui/src/commit_view.rs#L762-L798","documentation":"Guard in apply_stash: before applying, the stored stash sha is compared against the repository's current stash entry (stash_matches_index); when they diverge the stash list changed since the view was rendered, so applying could hit the wrong entry and is refused.","triggerScenarios":"Thrown at crates/git_ui/src/commit_view.rs:780 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Abort the apply and inform the user the stash list changed","Refresh the commit view / stash list so the UI shows current entries","Ask the user to re-invoke the action against the refreshed list","Never apply by index without verifying the sha first"],"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-14T05:17:10.506Z"}