plandex-ai/plandex · error

both target and current states must be provided

Error message

both target and current states must be provided

What it means

Validation guard at the top of AnalyzeRewind: rewind requires both a target plan state and a current plan state to compute the diff of files to change. One or both were empty/nil, so the rewind cannot be analyzed.

Source

Thrown at app/cli/lib/rewind.go:109

	}

	return affectedPaths
}

// RewindAnalysis captures all the information about a potential rewind operation
type RewindAnalysis struct {
	// Files that need to be modified when rewinding from current plan state to target plan state
	RequiredChanges map[string]string
	// Files that have been modified on disk relative to current plan state (potential conflicts)
	Conflicts map[string]bool
}

// AnalyzeRewind examines the three states (disk, current plan, target plan) to determine:
// 1. What files need to be changed to reach target state
// 2. Which of those changes would conflict with user modifications
func AnalyzeRewind(targetState, currentState *shared.CurrentPlanState) (*RewindAnalysis, error) {
	if targetState == nil || currentState == nil {
		return nil, fmt.Errorf("both target and current states must be provided")
	}

	// First determine what files need to be changed between current and target plan states
	requiredChanges := make(map[string]string)

	// Track all paths we need to examine for either changes or conflicts
	allPaths := make(map[string]bool)

	// Add paths from both states
	for path, context := range targetState.ContextsByPath {
		if context.ContextType != shared.ContextFileType {
			continue
		}
		allPaths[path] = true
	}
	for path, context := range currentState.ContextsByPath {
		if context.ContextType != shared.ContextFileType {
			continue

View on GitHub (pinned to e2d772072e)

Solutions

  1. Pass both current and target plan states to AnalyzeRewind
  2. Ensure the target branch/commit exists and has readable state
  3. Reject the rewind early in the CLI before analysis
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/cli/lib/rewind.go:109 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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