plandex-ai/plandex · error

failed to set pending results applied: %s

Error message

failed to set pending results applied: %s

What it means

apiApplyPlan calls the Plandex server's ApplyPlan API to mark a plan's pending results as applied and get back a commit summary. When the server responds with an error, the CLI wraps apiErr.Msg in this error. It means the server rejected or failed the apply-plan request, not a local git/file problem.

Source

Thrown at app/cli/lib/apply.go:588

		fmt.Println()
		fmt.Println("✅ Commands succeeded")
		onSuccess()
	}
}

func apiApplyPlan(planId, branch string) (string, error) {
	authVars := MustVerifyAuthVarsSilent(auth.Current.IntegratedModelsMode)

	var commitSummary string

	log.Println("Applying plan with API call")

	commitSummary, apiErr := api.Client.ApplyPlan(planId, branch, shared.ApplyPlanRequest{
		AuthVars: authVars,
	})

	if apiErr != nil {
		return "", fmt.Errorf("failed to set pending results applied: %s", apiErr.Msg)
	}

	return commitSummary, nil
}

func commitApplied(autoCommit bool, commitSummary string, updatedFiles []string, currentPlanState *shared.CurrentPlanState) (err error) {
	confirmed := autoCommit
	if !autoCommit {
		fmt.Println("✏️  Plandex can commit these updates with an automatically generated message.")
		fmt.Println()
		// fmt.Println("ℹ️  Only the files that Plandex is updating will be included the commit. Any other changes, staged or unstaged, will remain exactly as they are.")
		// fmt.Println()
		confirmed, err = term.ConfirmYesNo("Commit Plandex updates now?")
		if err != nil {
			return fmt.Errorf("failed to get confirmation user input: %s", err)
		}
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Re-run 'plandex apply' after confirming the plan and branch still exist (plandex current, plandex branches)
  2. Log in again (plandex login) to refresh an expired session token
  3. Verify integrated-model auth vars are set if IntegratedModelsMode is on (MustVerifyAuthVarsSilent runs first)
  4. Check the Plandex server logs for the underlying error reported in apiErr.Msg

Example fix

// before
if apiErr != nil {
  return "", fmt.Errorf("failed to set pending results applied: %s", apiErr.Msg)
}
// after
if apiErr != nil {
  if apiErr.Status == http.StatusUnauthorized {
    return "", fmt.Errorf("session expired, run 'plandex login': %s", apiErr.Msg)
  }
  return "", fmt.Errorf("failed to set pending results applied: %s", apiErr.Msg)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before applying
if out, err := exec.Command("plandex", "current").Output(); err != nil {
  log.Fatal("no active plan context: ", err)
}
if authVarsMissing() { log.Fatal("set integrated model auth vars before applying") }

Type guard

func isApiErr(err error) (msg string, ok bool) {
  type apiErr interface{ ErrorMsg() string }
  if e, ok := err.(apiErr); ok { return e.ErrorMsg(), true }
  return "", false
}

Try / catch

commitSummary, err := apiApplyPlan(planId, branch)
if err != nil {
  if strings.Contains(err.Error(), "unauthorized") || strings.Contains(err.Error(), "auth") {
    // prompt re-login then retry once
  }
  return fmt.Errorf("apply failed: %w", err)
}

Prevention

When it happens

Trigger: api.Client.ApplyPlan(planId, branch, shared.ApplyPlanRequest{AuthVars: ...}) returns a non-nil apiErr — server-side failure applying the plan, expired/invalid session auth, plan or branch not found, or missing integrated-model auth vars.

Common situations: Server restarted or plan context lost; branch renamed or deleted server-side; auth token expired mid-session; integrated models mode enabled without valid API keys configured.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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