plandex-ai/plandex · error

error getting current plan state: %v

Error message

error getting current plan state: %v

What it means

Raised in onFinishBuild's repo callback when db.GetCurrentPlanState fails after descriptions were fetched successfully. GetCurrentPlanState assembles the full current plan state (org, plan, convo descriptions) needed to compute the pending-changes summary for the build commit; its failure aborts the repo operation with 'error getting current plan state: %v'.

Source

Thrown at app/server/model/plan/build_finish.go:98

		}

		var unbuiltDescs []*db.ConvoMessageDescription
		for _, desc := range planDescs {
			if !desc.DidBuild || len(desc.BuildPathsInvalidated) > 0 {
				unbuiltDescs = append(unbuiltDescs, desc)
			}
		}

		// get fresh current plan state
		var currentPlan *shared.CurrentPlanState
		currentPlan, err = db.GetCurrentPlanState(db.CurrentPlanStateParams{
			OrgId:                    currentOrgId,
			PlanId:                   planId,
			ConvoMessageDescriptions: planDescs,
		})
		if err != nil {
			log.Printf("Error getting current plan state: %v\n", err)
			return fmt.Errorf("error getting current plan state: %v", err)
		}

		descErrCh := make(chan error, len(unbuiltDescs))
		for _, desc := range unbuiltDescs {
			if len(desc.Operations) > 0 {
				desc.DidBuild = true
				desc.BuildPathsInvalidated = map[string]bool{}
			}

			go func(desc *db.ConvoMessageDescription) {
				err := db.StoreDescription(desc)

				if err != nil {
					descErrCh <- fmt.Errorf("error storing description: %v", err)
					return
				}

				descErrCh <- nil

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the underlying wrapped error in server logs for which sub-read failed
  2. Verify the plan and org records still exist and IDs match
  3. Check DB health and retry — transient failures dominate here
  4. Ensure migrations ran so plan-state tables match the code's schema
  5. Avoid deleting/modifying the plan concurrently with an active build; retry build finish after

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

// confirm plan still exists before build-finish repo op
plan, err := db.GetPlan(orgId, planId)
if err != nil || plan == nil {
    return fmt.Errorf("plan %s not available for build finish", planId)
}

Try / catch

currentPlan, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{...})
if err != nil {
    return fmt.Errorf("error getting current plan state: %w", err)
}
// wrap with %w and retry transient DB errors with backoff

Prevention

When it happens

Trigger: db.GetCurrentPlanState(CurrentPlanStateParams{OrgId, PlanId, ConvoMessageDescriptions}) returns an error during build finish: missing plan record, invalid description data passed in, or DB read failure while assembling plan/file state.

Common situations: Plan was deleted or the org changed between build start and finish; corrupted/missing plan rows after partial migration; DB outage mid-build; inconsistencies from concurrent plan modifications while the build was finishing.

Related errors


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