plandex-ai/plandex · error

error getting current plan state: %v

Error message

error getting current plan state: %v

What it means

db.GetCurrentPlanState(db.CurrentPlanStateParams{...}) failed while assembling the current plan state (plan status, contexts, etc.) in tell_load.go, wrapped as 'error getting current plan state: %v'. This runs after the parallel loaders succeed, so the plan itself loaded but the state assembly query failed.

Source

Thrown at app/server/model/plan/tell_load.go:332

				go notify.NotifyErr(notify.SeverityError, fmt.Errorf("error loading plan: %v", err))

				active.StreamDoneCh <- &shared.ApiError{
					Type:   shared.ApiErrorTypeOther,
					Status: http.StatusInternalServerError,
					Msg:    fmt.Sprintf("Error loading plan: %v", err),
				}
				return err
			}
		}

		res, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{
			OrgId:    currentOrgId,
			PlanId:   planId,
			Contexts: modelContext,
		})

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

		currentPlan = res

		return nil
	})

	if err != nil {
		log.Printf("execTellPlan: error loading tell plan: %v\n", err)
		go notify.NotifyErr(notify.SeverityError, fmt.Errorf("error loading tell plan: %v", err))

		active.StreamDoneCh <- &shared.ApiError{
			Type:   shared.ApiErrorTypeOther,
			Status: http.StatusInternalServerError,
			Msg:    fmt.Sprintf("Error loading tell plan: %v", err),
		}
		return err
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the wrapped DB error in the log ('error loading tell plan: error getting current plan state: ...')
  2. Verify plan state tables exist and match the current schema
  3. Re-validate orgId/planId before load
  4. Retry once DB connectivity is restored

Example fix

// before
res, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{
    OrgId: currentOrgId, PlanId: planId, Contexts: modelContext,
})
if err != nil {
    return fmt.Errorf("error getting current plan state: %v", err)
}
// after
res, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{
    OrgId: currentOrgId, PlanId: planId, Contexts: modelContext,
})
if err != nil {
    return fmt.Errorf("error getting current plan state: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if currentOrgId == "" || planId == "" {
    return fmt.Errorf("cannot get current plan state: missing orgId or planId")
}

Type guard

if currentPlan == nil {
    return fmt.Errorf("current plan state is nil after load")
}

Try / catch

res, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{OrgId: currentOrgId, PlanId: planId, Contexts: modelContext})
if err != nil {
    return fmt.Errorf("error getting current plan state: %w", err)
}

Prevention

When it happens

Trigger: GetCurrentPlanState returns an error: DB failure, context/execution-context rows unreadable, or invalid modelContext passed in params.

Common situations: Corrupt or missing current_plan state rows; migration drift; DB connection dropped between the parallel loads and this call.

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/b9a35cfc77156bc0. Report an issue: GitHub.