{"record":{"id":"335288f078778252","repo":"plandex-ai/plandex","slug":"error-rejecting-plan-v","errorCode":null,"errorMessage":"error rejecting plan: %v","messagePattern":"error rejecting plan: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/result_helpers.go","lineNumber":831,"sourceCode":"\t\t\t\t\terrCh <- fmt.Errorf(\"panic in RejectAllResults: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\truntime.Goexit() // don't allow outer function to continue and double-send to channel\n\t\t\t\t}\n\t\t\t}()\n\t\t\terr := RejectPlanFile(orgId, planId, resultId, now)\n\n\t\t\tif err != nil {\n\t\t\t\terrCh <- fmt.Errorf(\"error rejecting result: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\terrCh <- nil\n\t\t}(resultId)\n\t}\n\n\tfor i := 0; i < len(files); i++ {\n\t\terr := <-errCh\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error rejecting plan: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc DeletePendingResultsForPaths(orgId, planId string, paths map[string]bool) error {\n\t// log.Println(\"Deleting pending results for paths\")\n\tresultsDir := getPlanResultsDir(orgId, planId)\n\tfiles, err := os.ReadDir(resultsDir)\n\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"error reading results dir: %v\", err)\n\t}","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/result_helpers.go#L813-L849","documentation":"RejectAllResults collects one value per spawned goroutine from errCh; any non-nil error is wrapped with this message and returned. It is the top-level failure of the reject-all operation — the inner error (panic, per-result failure) is nested inside.","triggerScenarios":"Any of the per-file goroutines sent a non-nil error (RejectPlanFile failure or recovered panic), causing the collect loop to abort on that receive. Note the loop returns early, so remaining goroutines' errors are abandoned but the buffered channel prevents leaks.","commonSituations":"First failing result masks the rest; bulk reject runs while an apply is concurrently rewriting the results dir; corrupt result files from an earlier crash make every run fail at the same item.","solutions":["Unwrap the nested error to identify the failing resultId and its root cause","Fix or remove the offending result file, then re-run RejectAllResults","Stop concurrent ApplyPlan/RejectAllResults operations on the same plan (serialize with a lock)","Add retry/skip semantics per result so one bad file doesn't abort the whole batch"],"exampleFix":"// before\nfor i := 0; i < len(files); i++ {\n    err := <-errCh\n    if err != nil {\n        return fmt.Errorf(\"error rejecting plan: %v\", err)\n    }\n}\n// after: collect all failures instead of aborting at the first\nvar errs []error\nfor i := 0; i < len(files); i++ {\n    if err := <-errCh; err != nil {\n        errs = append(errs, err)\n    }\n}\nif len(errs) > 0 {\n    return fmt.Errorf(\"error rejecting plan (%d failures): %v\", len(errs), errs[0])\n}","handlingStrategy":"fallback","validationCode":"if _, err := os.ReadDir(getPlanResultsDir(orgId, planId)); err != nil && !os.IsNotExist(err) {\n    return fmt.Errorf(\"results dir unreadable before reject-all: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"var errs []error\nfor i := 0; i < len(files); i++ {\n    if err := <-errCh; err != nil {\n        errs = append(errs, err)\n    }\n}\nif len(errs) > 0 {\n    return fmt.Errorf(\"error rejecting plan: %d of %d failed: %v\", len(errs), len(files), errors.Join(errs...))\n}","preventionTips":["Collect all per-result errors instead of aborting at the first receive","Unwrap nested errors to report the failing resultId upstream","Run bulk rejects when no apply job is active on the same plan","Add a dry-run mode that lists results to reject before mutating anything"],"tags":["go","concurrency","error-handling","batch"],"backgroundTag":"batch-operation-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}