plandex-ai/plandex · error
error getting current plan state: %v
Error message
error getting current plan state: %v
What it means
GetPlanDiffs starts by calling GetCurrentPlanState to assemble the plan's current file state, and wraps any failure as this error. Without the plan state, diffs cannot be computed, so the function aborts before creating its temp directory.
Source
Thrown at app/server/db/diff_helpers.go:22
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"
"runtime/debug"
shared "plandex-shared"
)
func GetPlanDiffs(orgId, planId string, plain bool) (string, error) {
planState, err := GetCurrentPlanState(CurrentPlanStateParams{
OrgId: orgId,
PlanId: planId,
})
if err != nil {
return "", fmt.Errorf("error getting current plan state: %v", err)
}
// create temp directory
tempDirPath, err := os.MkdirTemp(getOrgDir(orgId), "tmp-diffs-*")
if err != nil {
return "", fmt.Errorf("error creating temp dir: %v", err)
}
defer func() {
go os.RemoveAll(tempDirPath)
}()
// init a git repo in the temp dir
err = initGitRepo(tempDirPath)
if err != nil {
return "", fmt.Errorf("error initializing git repo: %v", err)View on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped %v error to see whether it was a DB error or a missing-plan error
- Verify orgId and planId refer to an existing plan visible to the caller
- Run migrations and confirm plan/file state tables are intact
- Add a pre-check (plan exists) before computing diffs for better error messages
Example fix
// before
planState, err := GetCurrentPlanState(CurrentPlanStateParams{OrgId: orgId, PlanId: planId})
if err != nil { return "", fmt.Errorf("error getting current plan state: %v", err) }
// after
if exists, err := PlanExists(orgId, planId); err != nil || !exists {
return "", fmt.Errorf("plan %s not found for org %s", planId, orgId)
}
planState, err := GetCurrentPlanState(CurrentPlanStateParams{OrgId: orgId, PlanId: planId}) Defensive patterns
Strategy: validation
Validate before calling
if orgId == "" || planId == "" {
return errors.New("orgId and planId are required for plan diffs")
}
exists, err := planExists(orgId, planId)
if err != nil || !exists {
return fmt.Errorf("plan %s not found for org %s", planId, orgId)
} Try / catch
diff, err := db.GetPlanDiffs(orgId, planId, files)
if err != nil && strings.Contains(err.Error(), "error getting current plan state") {
log.Printf("plan state unavailable: %v", err)
return fmt.Errorf("cannot diff plan %s: verify it exists and is accessible", planId)
} Prevention
- Validate orgId/planId and access permissions before computing diffs
- Verify plan creation completes before exposing diff endpoints
- Monitor DB health; plan-state queries fail during connectivity loss
- Keep plan/file state tables covered by migrations
When it happens
Trigger: An anonymous caller invokes GetPlanDiffs while GetCurrentPlanState fails: nonexistent planId/orgId, DB query error, or corrupted/missing plan files referenced by the state.
Common situations: Requesting diffs for a deleted or not-yet-created plan; cross-org access where the plan belongs to another org; database connectivity issues mid-request.
Related errors
- error getting current plan state: %v
- error getting plan settings: %v
- Error updating plan tokens:
- Error getting plan convo:
- Error getting plan summaries:
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/046bf9f083d9f8b3.
Report an issue: GitHub.