plandex-ai/plandex · error

error getting plan settings: %v

Error message

error getting plan settings: %v

What it means

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'.

Source

Thrown at app/server/handlers/plans_changes.go:163

	ctx, cancel := context.WithCancel(r.Context())

	var settings *shared.PlanSettings
	var currentPlanParams db.CurrentPlanStateParams
	var currentPlan *shared.CurrentPlanState

	err = db.ExecRepoOperation(db.ExecRepoOperationParams{
		OrgId:    auth.OrgId,
		UserId:   auth.User.Id,
		PlanId:   planId,
		Branch:   branch,
		Scope:    db.LockScopeRead,
		Ctx:      ctx,
		CancelFn: cancel,
	}, func(repo *db.GitRepo) error {
		var err error
		settings, err = db.GetPlanSettings(plan)
		if err != nil {
			return fmt.Errorf("error getting plan settings: %v", err)
		}

		currentPlanParams, err = db.GetFullCurrentPlanStateParams(auth.OrgId, planId)
		if err != nil {
			return fmt.Errorf("error getting current plan state params: %v", err)
		}

		currentPlan, err = db.GetCurrentPlanState(currentPlanParams)
		if err != nil {
			return fmt.Errorf("error getting current plan state: %v", err)
		}

		return nil
	})

	if err != nil {
		log.Printf("Error getting current plan state: %v\n", err)
		http.Error(w, "Error getting current plan state: "+err.Error(), http.StatusInternalServerError)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check logs for the wrapped error to identify the exact DB failure
  2. Verify the plan's settings row exists; re-create or backfill settings if the row is missing
  3. Retry once transient DB contention/connection issues clear
  4. Run pending migrations if the settings table schema is out of date

Example fix

// before: applying a plan with no settings row
client.ApplyPlan(brokenPlanId)
// after: ensure settings exist before applying
settings := client.GetPlanSettings(planId)
if settings == nil { client.UpdatePlanSettings(planId, defaultSettings) }
client.ApplyPlan(planId)
Defensive patterns

Strategy: retry

Validate before calling

// confirm the plan is initialized before applying
const plan = (await client.ListPlans()).find(p => p.id === planId)
if (!plan) throw new Error('plan not found: ' + planId)
await client.GetPlanSettings(planId) // throws early if settings row is missing

Try / catch

try {
  await client.ApplyPlan(planId)
} catch (err) {
  if (String(err.message).includes('error getting plan settings')) {
    await new Promise(r => setTimeout(r, 1500))
    await client.ApplyPlan(planId) // retry after transient DB issues
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: Applying a plan whose creation partially failed; DB pool exhaustion; migration drift so the settings table schema mismatches expectations.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/787f21970be116c1. Report an issue: GitHub.