{"record":{"id":"8d37ed9e15db83be","repo":"plandex-ai/plandex","slug":"failed-to-update-context-v","errorCode":null,"errorMessage":"failed to update context: %v","messagePattern":"failed to update context: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_update.go","lineNumber":268,"sourceCode":"\t\t\tfilesToLoad[context.FilePath] = context.Body\n\t\t}\n\t}\n\tfor id := range deleteIds {\n\t\tcontext := contextsById[id]\n\t\tif context.ContextType == shared.ContextFileType {\n\t\t\tfilesToLoad[context.FilePath] = \"\"\n\t\t}\n\t}\n\n\thasConflicts, err = checkContextConflicts(filesToLoad)\n\tif err != nil {\n\t\treturn UpdateContextResult{}, fmt.Errorf(\"failed to check context conflicts: %v\", err)\n\t}\n\n\tif len(req) > 0 {\n\t\tres, apiErr := api.Client.UpdateContext(CurrentPlanId, CurrentBranch, req)\n\t\tif apiErr != nil {\n\t\t\treturn UpdateContextResult{}, fmt.Errorf(\"failed to update context: %v\", apiErr)\n\t\t}\n\t\tmsg = res.Msg\n\t}\n\n\tif len(deleteIds) > 0 {\n\t\tres, apiErr := api.Client.DeleteContext(CurrentPlanId, CurrentBranch, shared.DeleteContextRequest{\n\t\t\tIds: deleteIds,\n\t\t})\n\t\tif apiErr != nil {\n\t\t\treturn UpdateContextResult{}, fmt.Errorf(\"failed to delete contexts: %v\", apiErr)\n\t\t}\n\t\tmsg += \" \" + res.Msg\n\t}\n\n\treturn UpdateContextResult{\n\t\tHasConflicts: hasConflicts,\n\t\tMsg:          strings.TrimSpace(msg),\n\t}, nil","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_update.go#L250-L286","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nres, apiErr := api.Client.UpdateContext(CurrentPlanId, CurrentBranch, req)\nif apiErr != nil { return UpdateContextResult{}, fmt.Errorf(\"failed to update context: %v\", apiErr) }\n// after (caller-side retry on transient failure)\nres, err := lib.UpdateContext(params)\nif err != nil && strings.Contains(err.Error(), \"failed to update context\") {\n    time.Sleep(2 * time.Second)\n    res, err = lib.UpdateContext(params)\n}","handlingStrategy":"try-catch","validationCode":"// confirm auth and plan reachability before mutating\nif _, err := api.Client.ListContext(CurrentPlanId, CurrentBranch); err != nil {\n    return fmt.Errorf(\"refresh auth/server state first: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, err := lib.UpdateContext(params)\nif err != nil && strings.Contains(err.Error(), \"failed to update context\") {\n    if isAuthError(err) { return fmt.Errorf(\"re-run `plandex sign-in` then retry\") }\n    if isTransient(err) { time.Sleep(2 * time.Second); return retry() }\n    return err\n}","preventionTips":["Re-authenticate before long operations","Keep context payloads within server size limits","Verify plan/branch exist before updating","Handle 5xx with bounded retries"],"tags":["go","api","network","http"],"backgroundTag":"api-request-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}