{"record":{"id":"dbd8826ac5533e10","repo":"plandex-ai/plandex","slug":"error-building-plan","errorCode":null,"errorMessage":"Error building plan","messagePattern":"Error building plan","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_exec.go","lineNumber":198,"sourceCode":"\t\t\tsettings:      settings,\n\t\t\torgUserConfig: orgUserConfig,\n\t\t},\n\t)\n\tnumBuilds, err := modelPlan.Build(modelPlan.BuildParams{\n\t\tClients:       res.clients,\n\t\tAuthVars:      res.authVars,\n\t\tPlan:          plan,\n\t\tBranch:        branch,\n\t\tAuth:          auth,\n\t\tSessionId:     requestBody.SessionId,\n\t\tOrgUserConfig: orgUserConfig,\n\t\tSettings:      settings,\n\t})\n\n\tif err != nil {\n\t\tlog.Printf(\"Error building plan: %v\\n\", err)\n\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error building plan: %v\", err))\n\t\thttp.Error(w, \"Error building plan\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif numBuilds == 0 {\n\t\tlog.Println(\"No builds were executed\")\n\t\tgo notify.NotifyErr(notify.SeverityInfo, fmt.Errorf(\"no builds were executed\"))\n\t\thttp.Error(w, shared.NoBuildsErr, http.StatusNotFound)\n\t\treturn\n\t}\n\n\tif requestBody.ConnectStream {\n\t\tstartResponseStream(r.Context(), w, auth, planId, branch, false)\n\t}\n\n\tlog.Println(\"Successfully processed request for BuildPlanHandler\")\n}\n\nfunc ConnectPlanHandler(w http.ResponseWriter, r *http.Request) {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_exec.go#L180-L216","documentation":"modelPlan.Build returned an error while executing the plan's pending builds (applying file changes produced by the LLM). The handler logs it, reports it asynchronously, and responds 500 'Error building plan' (note: unlike the tell path, the underlying detail is NOT included in the response, only in server logs).","triggerScenarios":"Build-plan POST where the build loop fails: git repo operations inside the plan's working copy fail, an LLM streaming call errors mid-build, file write/patch application fails, or the plan lock cannot be acquired.","commonSituations":"Concurrent modification of the plan branch (lock contention); LLM provider error mid-stream (quota, key revoked); filesystem full or permission issues on the server's plan storage; conflicting edits that cannot be applied.","solutions":["Check the server log for 'Error building plan: <detail>' — the root cause is only there, not in the HTTP response.","Stop any other active tell/build on the plan+branch, then retry to clear lock contention.","Validate LLM provider keys/quota if the detail points at a model call failure.","Check disk space and permissions on the plan storage volume; repair with `plandex` plan health commands if the repo is dirty.","Retry the build; if a specific file edit keeps failing, remove/reload that context and re-run."],"exampleFix":"// before: response hides the cause\nhttp.Error(w, \"Error building plan\", http.StatusInternalServerError)\n// after: include the detail like the tell path does\nhttp.Error(w, \"Error building plan: \"+err.Error(), http.StatusInternalServerError)","handlingStrategy":"fallback","validationCode":"// ensure no other operation holds the plan and provider key is present\nif os.Getenv(\"OPENAI_API_KEY\") == \"\" && len(req.ApiKeys) == 0 {\n    return errors.New(\"missing model credentials for build\")\n}","typeGuard":null,"tryCatchPattern":"if err := modelPlan.Build(params); err != nil {\n    log.Printf(\"Error building plan: %v\", err) // root cause is only in logs\n    if isLockConflict(err) { stopPlan(); time.Sleep(2*time.Second); return retryBuild() }\n    return fmt.Errorf(\"build failed; check server logs for detail: %w\", err)\n}","preventionTips":["Check server logs (not just the HTTP response) — the response omits the underlying detail.","Serialize tell→build per plan+branch; avoid concurrent clients.","Keep LLM keys funded/valid to prevent mid-stream provider failures.","Maintain free disk space and correct permissions on plan storage."],"tags":["plan-execution","build","git","server-error"],"backgroundTag":"plan-build-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"}