plandex-ai/plandex · error
failed to update context: %v
Error message
failed to update context: %v
What it means
After the conflict check, UpdateContext sends the update request via api.Client.UpdateContext(CurrentPlanId, CurrentBranch, req). Any server-side or transport failure is wrapped as 'failed to update context'. This is the actual mutation step of the context update.
Source
Thrown at app/cli/lib/context_update.go:268
filesToLoad[context.FilePath] = context.Body
}
}
for id := range deleteIds {
context := contextsById[id]
if context.ContextType == shared.ContextFileType {
filesToLoad[context.FilePath] = ""
}
}
hasConflicts, err = checkContextConflicts(filesToLoad)
if err != nil {
return UpdateContextResult{}, fmt.Errorf("failed to check context conflicts: %v", err)
}
if len(req) > 0 {
res, apiErr := api.Client.UpdateContext(CurrentPlanId, CurrentBranch, req)
if apiErr != nil {
return UpdateContextResult{}, fmt.Errorf("failed to update context: %v", apiErr)
}
msg = res.Msg
}
if len(deleteIds) > 0 {
res, apiErr := api.Client.DeleteContext(CurrentPlanId, CurrentBranch, shared.DeleteContextRequest{
Ids: deleteIds,
})
if apiErr != nil {
return UpdateContextResult{}, fmt.Errorf("failed to delete contexts: %v", apiErr)
}
msg += " " + res.Msg
}
return UpdateContextResult{
HasConflicts: hasConflicts,
Msg: strings.TrimSpace(msg),
}, nilView on GitHub (pinned to e2d772072e)
Solutions
- Read the wrapped apiErr for the HTTP status / server message
- Re-authenticate on 401/403 (plandex sign-in) and retry
- Reduce context size if the server rejected the payload (split large files, remove unneeded context)
- Verify the plan and branch still exist (plandex plans / plandex branches) and the server is reachable
Example fix
// before
res, apiErr := api.Client.UpdateContext(CurrentPlanId, CurrentBranch, req)
if apiErr != nil { return UpdateContextResult{}, fmt.Errorf("failed to update context: %v", apiErr) }
// after (caller-side retry on transient failure)
res, err := lib.UpdateContext(params)
if err != nil && strings.Contains(err.Error(), "failed to update context") {
time.Sleep(2 * time.Second)
res, err = lib.UpdateContext(params)
} Defensive patterns
Strategy: try-catch
Validate before calling
// confirm auth and plan reachability before mutating
if _, err := api.Client.ListContext(CurrentPlanId, CurrentBranch); err != nil {
return fmt.Errorf("refresh auth/server state first: %w", err)
} Try / catch
res, err := lib.UpdateContext(params)
if err != nil && strings.Contains(err.Error(), "failed to update context") {
if isAuthError(err) { return fmt.Errorf("re-run `plandex sign-in` then retry") }
if isTransient(err) { time.Sleep(2 * time.Second); return retry() }
return err
} Prevention
- Re-authenticate before long operations
- Keep context payloads within server size limits
- Verify plan/branch exist before updating
- Handle 5xx with bounded retries
When it happens
Trigger: api.Client.UpdateContext returns an error: plan/branch not found, auth token expired/invalid, network outage, server 5xx, request too large (context exceeds server limits), or plan locked by another operation.
Common situations: Expired session after long-running operations; pushing a huge file update exceeding server body limits; plan deleted from another terminal while updating; VPN/proxy blocking the daemon server.
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
- error listing contexts: %v
- error getting context body: %v
- error fetching users: %s
- error fetching pending invites: %s
- error getting custom model packs: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/8d37ed9e15db83be.
Report an issue: GitHub.