{"record":{"id":"6c3561a0e71835ee","repo":"plandex-ai/plandex","slug":"error-dropping-git-stash-v","errorCode":null,"errorMessage":"error dropping git stash: %v","messagePattern":"error dropping git stash: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/cli/lib/git.go","lineNumber":159,"sourceCode":"\t\t\tif !forceOverwrite {\n\t\t\t\treturn fmt.Errorf(\"conflict popping git stash: %s\", string(res))\n\t\t\t}\n\n\t\t\t// Parse the output to find which files have conflicts\n\t\t\tconflictFiles := parseConflictFiles(string(res))\n\n\t\t\tlog.Println(\"Conflicting files:\", conflictFiles)\n\n\t\t\tfor _, file := range conflictFiles {\n\t\t\t\t// Reset each conflicting file individually\n\t\t\t\tcheckoutRes, err := exec.Command(\"git\", \"checkout\", \"--ours\", file).CombinedOutput()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error resetting file %s: %v\", file, string(checkoutRes))\n\t\t\t\t}\n\t\t\t}\n\t\t\tdropRes, err := exec.Command(\"git\", \"stash\", \"drop\").CombinedOutput()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error dropping git stash: %v\", string(dropRes))\n\t\t\t}\n\t\t\treturn nil\n\t\t} else {\n\t\t\tlog.Println(\"No conflicts detected\")\n\n\t\t\treturn fmt.Errorf(\"error popping git stash: %v\", string(res))\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc GitClearUncommittedChanges() error {\n\tgitMutex.Lock()\n\tdefer gitMutex.Unlock()\n\n\t// Reset staged changes\n\tres, err := exec.Command(\"git\", \"reset\", \"--hard\").CombinedOutput()","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/git.go#L141-L177","documentation":"After resolving stash-pop conflicts with `git checkout --ours`, GitStashPop drops the stash with `git stash drop`. This error wraps a failure of that drop command, including git's output. The conflicted files were reset, but the stash entry remains, so the working tree is resolved but the stash is not cleaned up.","triggerScenarios":"GitStashPop(true) successfully reset all conflict files, then `git stash drop` failed — usually because there is no stash entry left (it was already popped/dropped or never created), the reflog/stash ref is corrupted, or the index is locked.","commonSituations":"Another process or a prior crashed run already consumed the stash (`No stash entries found`); concurrent GitStashPop calls racing on the same stash stack despite the mutex; corrupted .git/refs/stash.","solutions":["Check `git stash list`; if the message is 'No stash entries found', the stash is already gone and this is harmless — proceed.","Remove stale .git/index.lock if a git process is stuck.","If the stash ref is corrupted, delete it: `git stash clear` or remove .git/refs/stash.","Retry the drop manually: `git stash drop` and verify output.","Ensure only one process manipulates the stash stack at a time."],"exampleFix":"// before: treating drop failure as fatal even when stash is empty\nif err := lib.GitStashPop(true); err != nil { return err }\n// after: tolerate missing stash\nif err := lib.GitStashPop(true); err != nil && strings.Contains(err.Error(), \"No stash entries\") {\n    err = nil // stash already gone\n}","handlingStrategy":"try-catch","validationCode":"// Go: confirm a stash exists before pop/drop\nout, err := exec.Command(\"git\", \"stash\", \"list\").Output()\nhasStash := err == nil && strings.TrimSpace(string(out)) != \"\"","typeGuard":"func isStashDropError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error dropping git stash\")\n}","tryCatchPattern":"if err := lib.GitStashPop(true); err != nil {\n    if isStashDropError(err) && strings.Contains(err.Error(), \"No stash entries\") {\n        err = nil // stash already consumed; treat as success\n    }\n}","preventionTips":["Check `git stash list` before pop/drop flows so a missing stash is expected, not an error.","Never run multiple processes that mutate the stash stack concurrently.","Treat 'No stash entries found' as an idempotent success in cleanup paths.","Monitor for corrupted .git/refs/stash in long-lived checkouts."],"tags":["git","stash","drop","go"],"backgroundTag":"git-stash-drop-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}