{"record":{"id":"aa75eec925244cd8","repo":"plandex-ai/plandex","slug":"error-getting-pending-builds-by-path-v","errorCode":null,"errorMessage":"error getting pending builds by path: %v","messagePattern":"error getting pending builds by path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/plan/build_load.go","lineNumber":80,"sourceCode":"\t\t\t}\n\t\t\tmodelContext = res\n\n\t\t\terrCh <- nil\n\t\t}()\n\n\t\tgo func() {\n\t\t\tdefer func() {\n\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\tlog.Printf(\"panic in getPlanSettings: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\terrCh <- fmt.Errorf(\"error getting plan settings: %v\", r)\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\tres, err := active.PendingBuildsByPath(auth.OrgId, auth.User.Id, nil)\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error getting pending builds by path: %v\\n\", err)\n\t\t\t\terrCh <- fmt.Errorf(\"error getting pending builds by path: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tpendingBuildsByPath = res\n\n\t\t\terrCh <- nil\n\t\t}()\n\n\t\tgo func() {\n\t\t\tdefer func() {\n\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\tlog.Printf(\"panic in getPlanSettings: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\terrCh <- fmt.Errorf(\"error getting plan settings: %v\", r)\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\tres, err := db.GetPlanSettings(plan)\n\t\t\tif err != nil {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_load.go#L62-L98","documentation":"This error comes from loadPendingBuilds in app/server/model/plan/build_load.go when the goroutine calling active.PendingBuildsByPath(orgId, userId, nil) gets a non-nil error computing which builds are pending for each file path in the plan. The error is logged as 'Error getting pending builds by path' and forwarded to errCh wrapped as 'error getting pending builds by path: %v', aborting the build-stream load. The root database/state error is always appended after the colon.","triggerScenarios":"Calling the plan build/stream API while PendingBuildsByPath fails - typically an internal DB query over active builds for the org/user fails, or plan/branch state is inconsistent so the pending-build lookup errors out.","commonSituations":"Postgres connectivity problems or lock contention while other operations hold the plan repo lock; orphaned/stale active-build rows from a previously crashed server; querying a plan branch that was deleted or renamed mid-request.","solutions":["Inspect the underlying error after '%v' in the message and address that root cause (usually a DB query/connection failure).","Check for stale active-build rows for this plan and clear them if the server was previously killed mid-build.","Verify no other long-running operation is holding the plan's repo lock (ExecRepoOperation) causing timeouts; retry when idle.","Confirm the plan and branch still exist on the server (plandex branches) and retry the request.","Restart the Plandex server/DB if connection errors persist, then retry the build."],"exampleFix":"// caller-side retry pattern for this transient load failure\nfor i := 0; i < 3; i++ {\n    err := startPlanBuild(planId, branch)\n    if err == nil || !strings.Contains(err.Error(), \"error getting pending builds by path\") {\n        break\n    }\n    time.Sleep(2 * time.Second) // wait for DB/lock contention to clear, then retry\n}","handlingStrategy":"retry","validationCode":"// caller-side checks before starting the build\n// plandex branches --plan <planId>   -> target branch exists\n// ensure no other build/apply is running on the branch:\n// plandex ps --plan <planId>\nif planBusy(planId, branch) { return errors.New(\"plan already has an active operation; wait and retry\") }","typeGuard":null,"tryCatchPattern":"err := loadPlanBuild(planId, branch)\nif err != nil && strings.Contains(err.Error(), \"error getting pending builds by path\") {\n    // usually transient (DB/lock contention): retry with backoff\n    select {\n    case <-time.After(2 * time.Second):\n        return loadPlanBuild(planId, branch)\n    case <-ctx.Done():\n        return ctx.Err()\n    }\n}","preventionTips":["Serialize operations per plan/branch - don't run concurrent builds or applies on the same branch.","Clean up stale active-build rows after a crashed server before resuming builds.","Monitor DB latency/locks; lock contention under ExecRepoOperation is a common trigger.","Retry idempotent loads rather than recreating plans or force-deleting state."],"tags":["go","database","pending-builds","server","plandex"],"backgroundTag":"database-query-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"}