plandex-ai/plandex · error

error updating context: %v

Error message

error updating context: %v

What it means

Wrapper error from CheckOutdatedContextWithOutput when the confirmed context update (via UpdateContextWithOutput -> UpdateContext) fails for any reason — reqFn failure, conflict-check failure, or the UpdateContext/DeleteContext API calls. The wrapped %v carries the real cause from UpdateContext.

Source

Thrown at app/cli/lib/context_update.go:189

		confirmed, err = term.ConfirmYesNo("Update context now?")

		if err != nil {
			term.OutputErrorAndExit("failed to get user input: %s", err)
		}
	}

	if confirmed {
		reqFn := outdatedRes.ReqFn
		if reqFn == nil {
			return false, false, fmt.Errorf("no update request function provided")
		}
		_, err = UpdateContextWithOutput(UpdateContextParams{
			Contexts:    contexts,
			OutdatedRes: *outdatedRes,
			ReqFn:       reqFn,
		})
		if err != nil {
			return false, false, fmt.Errorf("error updating context: %v", err)
		}
		return true, true, nil
	} else {
		return true, false, nil
	}

}

type UpdateContextParams struct {
	Contexts    []*shared.Context
	OutdatedRes types.ContextOutdatedResult
	ReqFn       func() (map[string]*shared.UpdateContextParams, error)
}

type UpdateContextResult struct {
	HasConflicts bool
	Msg          string
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the wrapped inner error — it distinguishes reqFn failure vs conflict-check failure vs API failure
  2. Re-authenticate if the inner error is 401/403 (plandex sign-in)
  3. Retry after network issues; the plan context is only mutated on success of each API call
  4. Run plandex context to list current context and resolve conflicts before updating

Example fix

// before: letting the error bubble and aborting the command
_, _, err := lib.CheckOutdatedContextWithOutput(false, false, nil, paths)
if err != nil { return err }
// after: handle update failure without losing the outdated info
_, _, err := lib.CheckOutdatedContextWithOutput(false, false, nil, paths)
if err != nil {
    fmt.Println("context update failed; run `plandex context update` after fixing:", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check auth and plan state before confirming the update
if _, err := api.Client.ListContext(CurrentPlanId, CurrentBranch); err != nil {
    return fmt.Errorf("cannot reach plan context (auth/network?): %w", err)
}

Try / catch

_, _, err := lib.CheckOutdatedContextWithOutput(false, false, nil, paths)
if err != nil && strings.Contains(err.Error(), "error updating context") {
    // parse inner cause; retry on transient network errors
    if isTransient(err) { time.Sleep(time.Second); return retry() }
    return fmt.Errorf("context update failed: %w", err)
}

Prevention

When it happens

Trigger: User confirms 'Update context now?' (or autoConfirm=true) and UpdateContextWithOutput returns an error: reqFn() fails, context conflict check fails, or api.Client.UpdateContext / DeleteContext returns an error (auth expired, network, plan locked).

Common situations: Server unreachable or session token expired while applying an update; local files changed again mid-update causing conflicts; deleteIds referencing contexts already deleted on the server from another session.

Related errors


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