{"record":{"id":"787f21970be116c1","repo":"plandex-ai/plandex","slug":"error-getting-plan-settings-v","errorCode":null,"errorMessage":"error getting plan settings: %v","messagePattern":"error getting plan settings: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_changes.go","lineNumber":163,"sourceCode":"\tctx, cancel := context.WithCancel(r.Context())\n\n\tvar settings *shared.PlanSettings\n\tvar currentPlanParams db.CurrentPlanStateParams\n\tvar currentPlan *shared.CurrentPlanState\n\n\terr = db.ExecRepoOperation(db.ExecRepoOperationParams{\n\t\tOrgId:    auth.OrgId,\n\t\tUserId:   auth.User.Id,\n\t\tPlanId:   planId,\n\t\tBranch:   branch,\n\t\tScope:    db.LockScopeRead,\n\t\tCtx:      ctx,\n\t\tCancelFn: cancel,\n\t}, func(repo *db.GitRepo) error {\n\t\tvar err error\n\t\tsettings, err = db.GetPlanSettings(plan)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error getting plan settings: %v\", err)\n\t\t}\n\n\t\tcurrentPlanParams, err = db.GetFullCurrentPlanStateParams(auth.OrgId, planId)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error getting current plan state params: %v\", err)\n\t\t}\n\n\t\tcurrentPlan, err = db.GetCurrentPlanState(currentPlanParams)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error getting current plan state: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Printf(\"Error getting current plan state: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting current plan state: \"+err.Error(), http.StatusInternalServerError)","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_changes.go#L145-L181","documentation":"Returned from the ApplyPlan repo operation when db.GetPlanSettings fails to load the plan's settings row before applying. The ExecRepoOperation closure aborts and the handler responds 500 'Error getting current plan state: error getting plan settings'.","triggerScenarios":"POST apply-plan where db.GetPlanSettings(plan) returns a DB error: no settings row for the plan (plan created but settings insert failed/rolled back), connection failure, or timeout while the repo operation holds its lock.","commonSituations":"Applying a plan whose creation partially failed; DB pool exhaustion; migration drift so the settings table schema mismatches expectations.","solutions":["Check logs for the wrapped error to identify the exact DB failure","Verify the plan's settings row exists; re-create or backfill settings if the row is missing","Retry once transient DB contention/connection issues clear","Run pending migrations if the settings table schema is out of date"],"exampleFix":"// before: applying a plan with no settings row\nclient.ApplyPlan(brokenPlanId)\n// after: ensure settings exist before applying\nsettings := client.GetPlanSettings(planId)\nif settings == nil { client.UpdatePlanSettings(planId, defaultSettings) }\nclient.ApplyPlan(planId)","handlingStrategy":"retry","validationCode":"// confirm the plan is initialized before applying\nconst plan = (await client.ListPlans()).find(p => p.id === planId)\nif (!plan) throw new Error('plan not found: ' + planId)\nawait client.GetPlanSettings(planId) // throws early if settings row is missing","typeGuard":null,"tryCatchPattern":"try {\n  await client.ApplyPlan(planId)\n} catch (err) {\n  if (String(err.message).includes('error getting plan settings')) {\n    await new Promise(r => setTimeout(r, 1500))\n    await client.ApplyPlan(planId) // retry after transient DB issues\n  }\n}","preventionTips":["Verify a plan's settings exist (GetPlanSettings) before applying","Apply migrations after server upgrades so the settings table schema is current","Retry transient DB failures — repo operations are transactional and safe to re-run"],"tags":["database","plans","settings"],"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-14T00:17:10.932Z"}