{"record":{"id":"cb0022a76efa43c0","repo":"plandex-ai/plandex","slug":"error-getting-plan-applies-v","errorCode":null,"errorMessage":"error getting plan applies: %v","messagePattern":"error getting plan applies: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/result_helpers.go","lineNumber":242,"sourceCode":"\t\t\tif context.FilePath != \"\" {\n\t\t\t\tcontextsByPath[context.FilePath] = context\n\t\t\t}\n\t\t}\n\n\t\terrCh <- nil\n\t}()\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif r := recover(); r != nil {\n\t\t\t\tlog.Printf(\"panic in GetCurrentPlanState: %v\\n%s\", r, debug.Stack())\n\t\t\t\terrCh <- fmt.Errorf(\"panic in GetCurrentPlanState: %v\\n%s\", r, debug.Stack())\n\t\t\t\truntime.Goexit() // don't allow outer function to continue and double-send to channel\n\t\t\t}\n\t\t}()\n\t\tres, err := GetPlanApplies(orgId, planId)\n\t\tif err != nil {\n\t\t\terrCh <- fmt.Errorf(\"error getting plan applies: %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\tfor _, apply := range res {\n\t\t\tplanApplies = append(planApplies, apply.ToApi())\n\t\t}\n\n\t\terrCh <- nil\n\t}()\n\n\tfor i := 0; i < 4; i++ {\n\t\terr := <-errCh\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tvar apiPlanFileResults []*shared.PlanFileResult","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/result_helpers.go#L224-L260","documentation":"GetCurrentPlanState fetches plan applies in a worker goroutine via GetPlanApplies(orgId, planId). A non-nil error from that call is re-wrapped here as 'error getting plan applies: %v' and sent to errCh, aborting the full plan-state load and returning this error to the caller.","triggerScenarios":"Calling GetCurrentPlanState when the plan-applies storage read fails for the org/plan — e.g. missing applies directory (non-NotExist error), permissions problem, or underlying query failure inside GetPlanApplies.","commonSituations":"Plan storage partially deleted (applies removed but plan metadata remains); running the server with a user lacking read access to the applies path; transient storage backend errors during high load; org/plan id mismatch after an environment copy.","solutions":["Inspect the wrapped inner error to distinguish permissions vs missing storage vs backend failure","Verify the plan's applies storage exists and is readable by the server process","Correct orgId/planId if data was copied between environments","Restore or recreate the missing applies data from backup","Retry if the inner error indicates a transient backend issue"],"exampleFix":"// before\nres, err := GetPlanApplies(orgId, planId)\nif err != nil {\n    return nil, err\n}\n// after\nres, err := GetPlanApplies(orgId, planId)\nif err != nil {\n    log.Printf(\"plan applies unavailable for %s/%s: %v; continuing without applies\", orgId, planId, err)\n    res = nil\n}","handlingStrategy":"retry","validationCode":"if _, err := GetPlanApplies(orgId, planId); err != nil {\n    if !os.IsNotExist(err) {\n        // transient-looking failure; back off before calling GetCurrentPlanState\n        time.Sleep(500 * time.Millisecond)\n    }\n}","typeGuard":"func isPlanAppliesError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error getting plan applies\")\n}","tryCatchPattern":"var planState *shared.CurrentPlanState\nvar err error\nfor attempt := 0; attempt < 3; attempt++ {\n    planState, err = GetCurrentPlanState(params)\n    if err == nil || !isPlanAppliesError(err) {\n        break\n    }\n    time.Sleep(time.Duration(attempt+1) * 500 * time.Millisecond)\n}","preventionTips":["Retry with backoff for transient storage failures behind GetPlanApplies","Ensure the plan data root is not partially deleted by cleanup jobs","Run the server under a user with read access to the applies storage","Verify org/plan ids after copying data between environments"],"tags":["go","plan-state","error-wrapping","storage"],"backgroundTag":"plan-applies-load-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"}